these two functions will return the radii of impact for a target object of mass m and radius r as well as it s effective cross sectional area sigma that is to say any projectile with velocity v passing within will impact the target object with mass m the derivation of which is given at the bottom of this file the derivation shows that a projectile does not need to aim directly at the target body in order to hit it as rcapturertarget astronomers refer to the effective cross section for capture as rcapture2 this algorithm does not account for an nbody problem input params targetbodyradius radius of the central body si units meters m targetbodymass mass of the central body si units kilograms kg projectilevelocity velocity of object moving toward central body si units meterssecond ms returns captureradii6 957e8 1 99e30 25000 0 17209590691 0 captureradii6 957e8 1 99e30 25000 0 traceback most recent call last valueerror radius cannot be less than 0 captureradii6 957e8 1 99e30 25000 0 traceback most recent call last valueerror mass cannot be less than 0 captureradii6 957e8 1 99e30 c1 traceback most recent call last valueerror cannot go beyond speed of light returned si units meters m input param captureradius the radius of orbital capture and impact for a central body of mass m and a projectile moving towards it with velocity v si units meters m returns capturearea17209590691 9 304455331329126e20 capturearea1 traceback most recent call last valueerror cannot have a capture radius less than 0 returned si units metersmeters m2 derivation let mttarget mass rttarget radius vprojectilevelocity r0radius of projectile at instant 0 to cm of target vpv at closest approach rpradius from projectile to target cm at closest approach rcapture radius of impact for projectile with velocity v 1at time0 the projectile s energy falling from infinity eku0 5mv20 einitial0 5mv2 2at time0 the angular momentum of the projectile relative to cm target linitialmr0vsinmr0vrcapturer0mvrcapture limvrcapture 3the energy of the projectile at closest approach will be its kinetic energy at closest approach plus gravitational potential energygmmr epkpupep0 5mvp2gmtmrp ep0 0 5mvp2gmtmrp 4the angular momentum of the projectile relative to the target at closest approach will be lpmrpvpsin however relative to the target 90 sin901 lpmrpvp 5using conservation of angular momentum and energy we can write a quadratic equation that solves for rp a eiep 0 5mv20 5mvp2gmtmrp v2vp22gmtrp b lilp mvrcapturemrpvp vrcapturerpvp vpvrcapturerp c b plugs int a v2vrcapturerp22gmtrp v2v2rc2rp22gmtrp0 v2rp22gmtrpv2rc20 d using the quadratic formula we ll solve for rp then rearrange to solve to rcapture rp2gmt sqrt4g2mt2 4v4rc22v2 rpgmt sqrtg2mtv4rc2v2 rp0 is something we can ignore as it has no physical meaning for our purposes rpgmtv2 sqrtg2mt2v4 rc2 ewe are trying to solve for rc we are looking for impact so we want rprt rt gmtv2 sqrtg2mt2v4 rc2 rt gmtv22 g2mt2v4 rc2 rt2 2gmtrtv2 g2mt2v4 g2mt2v4 rc2 rt2 2gmtrtv2 rc2 rt2 1 2gmtrt 1v2 rc2 escape velocity sqrt2gmr vescape22gmr rt2 1 vesc2v2 rc2 6 rcapture rt sqrt1 vesc2v2 source problem set 3 8 c fall2017honors astronomyprofessor rachel bezanson source 2 http www nssc ac cnwxzygxweixin201607p020160718380095698873 pdf 8 8 planetary rendezvous pg 368 these two functions will return the radii of impact for a target object of mass m and radius r as well as it s effective cross sectional area σ sigma that is to say any projectile with velocity v passing within σ will impact the target object with mass m the derivation of which is given at the bottom of this file the derivation shows that a projectile does not need to aim directly at the target body in order to hit it as r_capture r_target astronomers refer to the effective cross section for capture as σ π r_capture 2 this algorithm does not account for an n body problem input params target_body_radius radius of the central body si units meters m target_body_mass mass of the central body si units kilograms kg projectile_velocity velocity of object moving toward central body si units meters second m s returns capture_radii 6 957e8 1 99e30 25000 0 17209590691 0 capture_radii 6 957e8 1 99e30 25000 0 traceback most recent call last valueerror radius cannot be less than 0 capture_radii 6 957e8 1 99e30 25000 0 traceback most recent call last valueerror mass cannot be less than 0 capture_radii 6 957e8 1 99e30 c 1 traceback most recent call last valueerror cannot go beyond speed of light returned si units meters m input param capture_radius the radius of orbital capture and impact for a central body of mass m and a projectile moving towards it with velocity v si units meters m returns capture_area 17209590691 9 304455331329126e 20 capture_area 1 traceback most recent call last valueerror cannot have a capture radius less than 0 returned si units meters meters m 2 derivation let mt target mass rt target radius v projectile_velocity r_0 radius of projectile at instant 0 to cm of target v_p v at closest approach r_p radius from projectile to target cm at closest approach r_capture radius of impact for projectile with velocity v 1 at time 0 the projectile s energy falling from infinity e k u 0 5 m v 2 0 e_initial 0 5 m v 2 2 at time 0 the angular momentum of the projectile relative to cm target l_initial m r_0 v sin θ m r_0 v r_capture r_0 m v r_capture l_i m v r_capture 3 the energy of the projectile at closest approach will be its kinetic energy at closest approach plus gravitational potential energy gmm r e_p k_p u_p e_p 0 5 m v_p 2 g mt m r_p e_p 0 0 5 m v_p 2 g mt m r_p 4 the angular momentum of the projectile relative to the target at closest approach will be l_p m r_p v_p sin θ however relative to the target θ 90 sin 90 1 l_p m r_p v_p 5 using conservation of angular momentum and energy we can write a quadratic equation that solves for r_p a ei ep 0 5 m v 2 0 5 m v_p 2 g mt m r_p v 2 v_p 2 2 g mt r_p b li lp m v r_capture m r_p v_p v r_capture r_p v_p v_p v r_capture r_p c b plugs int a v 2 v r_capture r_p 2 2 g mt r_p v 2 v 2 r_c 2 r_p 2 2 g mt r_p 0 v 2 r_p 2 2 g mt r_p v 2 r_c 2 0 d using the quadratic formula we ll solve for r_p then rearrange to solve to r_capture r_p 2 g mt sqrt 4 g 2 mt 2 4 v 4 r_c 2 2 v 2 r_p g mt sqrt g 2 mt v 4 r_c 2 v 2 r_p 0 is something we can ignore as it has no physical meaning for our purposes r_p g mt v 2 sqrt g 2 mt 2 v 4 r_c 2 e we are trying to solve for r_c we are looking for impact so we want r_p rt rt g mt v 2 sqrt g 2 mt 2 v 4 r_c 2 rt g mt v 2 2 g 2 mt 2 v 4 r_c 2 rt 2 2 g mt rt v 2 g 2 mt 2 v 4 g 2 mt 2 v 4 r_c 2 rt 2 2 g mt rt v 2 r_c 2 rt 2 1 2 g mt rt 1 v 2 r_c 2 escape velocity sqrt 2gm r v_escape 2 2gm r rt 2 1 v_esc 2 v 2 r_c 2 6 r_capture rt sqrt 1 v_esc 2 v 2 source problem set 3 8 c fall_2017 honors astronomy professor rachel bezanson source 2 http www nssc ac cn wxzygx weixin 201607 p020160718380095698873 pdf 8 8 planetary rendezvous pg 368
from math import pow, sqrt

from scipy.constants import G, c, pi




def capture_radii(
    target_body_radius: float, target_body_mass: float, projectile_velocity: float
) -> float:
    

    if target_body_mass < 0:
        raise ValueError("Mass cannot be less than 0")
    if target_body_radius < 0:
        raise ValueError("Radius cannot be less than 0")
    if projectile_velocity > c:
        raise ValueError("Cannot go beyond speed of light")

    escape_velocity_squared = (2 * G * target_body_mass) / target_body_radius
    capture_radius = target_body_radius * sqrt(
        1 + escape_velocity_squared / pow(projectile_velocity, 2)
    )
    return round(capture_radius, 0)


def capture_area(capture_radius: float) -> float:
    

    if capture_radius < 0:
        raise ValueError("Cannot have a capture radius less than 0")
    sigma = pi * pow(capture_radius, 2)
    return round(sigma, 0)


if __name__ == "__main__":
    from doctest import testmod

    testmod()