r""" Returns the horizontal distance that the object cover Formula: .. math:: \frac{v_0^2 \cdot \sin(2 \alpha)}{g} v_0 - \text{initial velocity} \alpha - \text{angle} >>> horizontal_distance(30, 45) 91.77 >>> horizontal_distance(100
(init_velocity: float, angle: float)
| 46 | |
| 47 | |
| 48 | def horizontal_distance(init_velocity: float, angle: float) -> float: |
| 49 | r""" |
| 50 | Returns the horizontal distance that the object cover |
| 51 | |
| 52 | Formula: |
| 53 | .. math:: |
| 54 | \frac{v_0^2 \cdot \sin(2 \alpha)}{g} |
| 55 | |
| 56 | v_0 - \text{initial velocity} |
| 57 | |
| 58 | \alpha - \text{angle} |
| 59 | |
| 60 | >>> horizontal_distance(30, 45) |
| 61 | 91.77 |
| 62 | >>> horizontal_distance(100, 78) |
| 63 | 414.76 |
| 64 | >>> horizontal_distance(-1, 20) |
| 65 | Traceback (most recent call last): |
| 66 | ... |
| 67 | ValueError: Invalid velocity. Should be a positive number. |
| 68 | >>> horizontal_distance(30, -20) |
| 69 | Traceback (most recent call last): |
| 70 | ... |
| 71 | ValueError: Invalid angle. Range is 1-90 degrees. |
| 72 | """ |
| 73 | check_args(init_velocity, angle) |
| 74 | radians = deg_to_rad(2 * angle) |
| 75 | return round(init_velocity**2 * sin(radians) / g, 2) |
| 76 | |
| 77 | |
| 78 | def max_height(init_velocity: float, angle: float) -> float: |