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 Return
(
target_body_radius: float, target_body_mass: float, projectile_velocity: float
)
| 18 | |
| 19 | |
| 20 | def capture_radii( |
| 21 | target_body_radius: float, target_body_mass: float, projectile_velocity: float |
| 22 | ) -> float: |
| 23 | """ |
| 24 | Input Params: |
| 25 | ------------- |
| 26 | target_body_radius: Radius of the central body SI units: meters | m |
| 27 | target_body_mass: Mass of the central body SI units: kilograms | kg |
| 28 | projectile_velocity: Velocity of object moving toward central body |
| 29 | SI units: meters/second | m/s |
| 30 | Returns: |
| 31 | -------- |
| 32 | >>> capture_radii(6.957e8, 1.99e30, 25000.0) |
| 33 | 17209590691.0 |
| 34 | >>> capture_radii(-6.957e8, 1.99e30, 25000.0) |
| 35 | Traceback (most recent call last): |
| 36 | ... |
| 37 | ValueError: Radius cannot be less than 0 |
| 38 | >>> capture_radii(6.957e8, -1.99e30, 25000.0) |
| 39 | Traceback (most recent call last): |
| 40 | ... |
| 41 | ValueError: Mass cannot be less than 0 |
| 42 | >>> capture_radii(6.957e8, 1.99e30, c+1) |
| 43 | Traceback (most recent call last): |
| 44 | ... |
| 45 | ValueError: Cannot go beyond speed of light |
| 46 | |
| 47 | Returned SI units: |
| 48 | ------------------ |
| 49 | meters | m |
| 50 | """ |
| 51 | |
| 52 | if target_body_mass < 0: |
| 53 | raise ValueError("Mass cannot be less than 0") |
| 54 | if target_body_radius < 0: |
| 55 | raise ValueError("Radius cannot be less than 0") |
| 56 | if projectile_velocity > c: |
| 57 | raise ValueError("Cannot go beyond speed of light") |
| 58 | |
| 59 | escape_velocity_squared = (2 * G * target_body_mass) / target_body_radius |
| 60 | capture_radius = target_body_radius * sqrt( |
| 61 | 1 + escape_velocity_squared / pow(projectile_velocity, 2) |
| 62 | ) |
| 63 | return round(capture_radius, 0) |
| 64 | |
| 65 | |
| 66 | def capture_area(capture_radius: float) -> float: |
nothing calls this directly
no outgoing calls
no test coverage detected