r""" Returns total time of the motion Formula: .. math:: \frac{2 v_0 \cdot \sin (\alpha)}{g} v_0 - \text{initial velocity} \alpha - \text{angle} >>> total_time(30, 45) 4.33 >>> total_time(100, 78) 19.95 >>> total_time(-10, 4
(init_velocity: float, angle: float)
| 106 | |
| 107 | |
| 108 | def total_time(init_velocity: float, angle: float) -> float: |
| 109 | r""" |
| 110 | Returns total time of the motion |
| 111 | |
| 112 | Formula: |
| 113 | .. math:: |
| 114 | \frac{2 v_0 \cdot \sin (\alpha)}{g} |
| 115 | |
| 116 | v_0 - \text{initial velocity} |
| 117 | |
| 118 | \alpha - \text{angle} |
| 119 | |
| 120 | >>> total_time(30, 45) |
| 121 | 4.33 |
| 122 | >>> total_time(100, 78) |
| 123 | 19.95 |
| 124 | >>> total_time(-10, 40) |
| 125 | Traceback (most recent call last): |
| 126 | ... |
| 127 | ValueError: Invalid velocity. Should be a positive number. |
| 128 | >>> total_time(30, "b") |
| 129 | Traceback (most recent call last): |
| 130 | ... |
| 131 | TypeError: Invalid angle. Should be an integer or float. |
| 132 | """ |
| 133 | check_args(init_velocity, angle) |
| 134 | radians = deg_to_rad(angle) |
| 135 | return round(2 * init_velocity * sin(radians) / g, 2) |
| 136 | |
| 137 | |
| 138 | def test_motion() -> None: |