/// Two planetesimals collide and form one planet
Two planetesimals collide and form one planet
Two planetesimals collide and form one planet
fn coalesce_two_planets(a: &Planetesimal, b: &Planetesimal) -> Planetesimal {
    let new_mass = a.mass + b.mass;
    let new_axis = new_mass / (a.mass / a.a + b.mass / b.a);
    let term1 = a.mass * (a.a * (1.0 - a.e.powf(2.0))).sqrt();
    let term2 = b.mass * (b.a * (1.0 - b.e.powf(2.0))).sqrt();
    let term3 = (term1 + term2) / (new_mass * new_axis.sqrt());
    let term4 = 1.0 - term3.powf(2.0);
    let new_eccn = term4.abs().sqrt();
    let mut coalesced = a.clone();
    coalesced.mass = new_mass;
    coalesced.a = new_axis;
    coalesced.e = new_eccn;
    coalesced.is_gas_giant = a.is_gas_giant || b.is_gas_giant;
    coalesced.radius = kothari_radius(
        &coalesced.mass,
        &coalesced.is_gas_giant,
        &coalesced.orbit_zone,
    );
    coalesced.has_collision = true;
    coalesced
}
fn coalesce_two_planets ( a : & Planetesimal , b : & Planetesimal ) -> Planetesimal { let new_mass = a . mass + b . mass ; let new_axis = new_mass / ( a . mass / a . a + b . mass / b . a ) ; let term1 = a . mass * ( a . a * ( 1.0 - a . e . powf ( 2.0 ) ) ) . sqrt ( ) ; let term2 = b . mass * ( b . a * ( 1.0 - b . e . powf ( 2.0 ) ) ) . sqrt ( ) ; let term3 = ( term1 + term2 ) / ( new_mass * new_axis . sqrt ( ) ) ; let term4 = 1.0 - term3 . powf ( 2.0 ) ; let new_eccn = term4 . abs ( ) . sqrt ( ) ; let mut coalesced = a . clone ( ) ; coalesced . mass = new_mass ; coalesced . a = new_axis ; coalesced . e = new_eccn ; coalesced . is_gas_giant = a . is_gas_giant || b . is_gas_giant ; coalesced . radius = kothari_radius ( & coalesced . mass , & coalesced . is_gas_giant , & coalesced . orbit_zone , ) ; coalesced . has_collision = true ; coalesced }
Two planetesimals collide and form one planet
Two planetesimals collide and form one planet
a
&Planetesimal
b
&Planetesimal