Calculates β = v/c, the given velocity as a fraction of c >>> beta(c) 1.0 >>> beta(199792458) 0.666435904801848 >>> beta(1e5) 0.00033356409519815205 >>> beta(0.2) Traceback (most recent call last): ... ValueError: Speed must be greater than or equal to
(velocity: float)
| 39 | |
| 40 | # Vehicle's speed divided by speed of light (no units) |
| 41 | def beta(velocity: float) -> float: |
| 42 | """ |
| 43 | Calculates β = v/c, the given velocity as a fraction of c |
| 44 | >>> beta(c) |
| 45 | 1.0 |
| 46 | >>> beta(199792458) |
| 47 | 0.666435904801848 |
| 48 | >>> beta(1e5) |
| 49 | 0.00033356409519815205 |
| 50 | >>> beta(0.2) |
| 51 | Traceback (most recent call last): |
| 52 | ... |
| 53 | ValueError: Speed must be greater than or equal to 1! |
| 54 | """ |
| 55 | if velocity > c: |
| 56 | raise ValueError("Speed must not exceed light speed 299,792,458 [m/s]!") |
| 57 | elif velocity < 1: |
| 58 | # Usually the speed should be much higher than 1 (c order of magnitude) |
| 59 | raise ValueError("Speed must be greater than or equal to 1!") |
| 60 | |
| 61 | return velocity / c |
| 62 | |
| 63 | |
| 64 | def gamma(velocity: float) -> float: |
no outgoing calls
no test coverage detected