11"""
22Horizontal Projectile Motion problem in physics.
3+
34This algorithm solves a specific problem in which
4- the motion starts from the ground as can be seen below:
5- (v = 0)
6- * *
7- * *
8- * *
9- * *
10- * *
11- * *
12- GROUND GROUND
5+ the motion starts from the ground as can be seen below::
6+
7+ (v = 0)
8+ * *
9+ * *
10+ * *
11+ * *
12+ * *
13+ * *
14+ GROUND GROUND
15+
1316For more info: https://en.wikipedia.org/wiki/Projectile_motion
1417"""
1518
@@ -43,14 +46,17 @@ def check_args(init_velocity: float, angle: float) -> None:
4346
4447
4548def horizontal_distance (init_velocity : float , angle : float ) -> float :
46- """
49+ r """
4750 Returns the horizontal distance that the object cover
51+
4852 Formula:
49- v_0^2 * sin(2 * alpha)
50- ---------------------
51- g
52- v_0 - initial velocity
53- alpha - angle
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+
5460 >>> horizontal_distance(30, 45)
5561 91.77
5662 >>> horizontal_distance(100, 78)
@@ -70,14 +76,17 @@ def horizontal_distance(init_velocity: float, angle: float) -> float:
7076
7177
7278def max_height (init_velocity : float , angle : float ) -> float :
73- """
79+ r """
7480 Returns the maximum height that the object reach
81+
7582 Formula:
76- v_0^2 * sin^2(alpha)
77- --------------------
78- 2g
79- v_0 - initial velocity
80- alpha - angle
83+ .. math::
84+ \frac{v_0^2 \cdot \sin^2 (\alpha)}{2 g}
85+
86+ v_0 - \text{initial velocity}
87+
88+ \alpha - \text{angle}
89+
8190 >>> max_height(30, 45)
8291 22.94
8392 >>> max_height(100, 78)
@@ -97,14 +106,17 @@ def max_height(init_velocity: float, angle: float) -> float:
97106
98107
99108def total_time (init_velocity : float , angle : float ) -> float :
100- """
109+ r """
101110 Returns total time of the motion
111+
102112 Formula:
103- 2 * v_0 * sin(alpha)
104- --------------------
105- g
106- v_0 - initial velocity
107- alpha - angle
113+ .. math::
114+ \frac{2 v_0 \cdot \sin (\alpha)}{g}
115+
116+ v_0 - \text{initial velocity}
117+
118+ \alpha - \text{angle}
119+
108120 >>> total_time(30, 45)
109121 4.33
110122 >>> total_time(100, 78)
@@ -125,6 +137,8 @@ def total_time(init_velocity: float, angle: float) -> float:
125137
126138def test_motion () -> None :
127139 """
140+ Test motion
141+
128142 >>> test_motion()
129143 """
130144 v0 , angle = 25 , 20
0 commit comments