1
1
"""
2
2
Horizontal Projectile Motion problem in physics.
3
+
3
4
This 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
+
13
16
For more info: https://en.wikipedia.org/wiki/Projectile_motion
14
17
"""
15
18
@@ -43,14 +46,17 @@ def check_args(init_velocity: float, angle: float) -> None:
43
46
44
47
45
48
def horizontal_distance (init_velocity : float , angle : float ) -> float :
46
- """
49
+ r """
47
50
Returns the horizontal distance that the object cover
51
+
48
52
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
+
54
60
>>> horizontal_distance(30, 45)
55
61
91.77
56
62
>>> horizontal_distance(100, 78)
@@ -70,14 +76,17 @@ def horizontal_distance(init_velocity: float, angle: float) -> float:
70
76
71
77
72
78
def max_height (init_velocity : float , angle : float ) -> float :
73
- """
79
+ r """
74
80
Returns the maximum height that the object reach
81
+
75
82
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
+
81
90
>>> max_height(30, 45)
82
91
22.94
83
92
>>> max_height(100, 78)
@@ -97,14 +106,17 @@ def max_height(init_velocity: float, angle: float) -> float:
97
106
98
107
99
108
def total_time (init_velocity : float , angle : float ) -> float :
100
- """
109
+ r """
101
110
Returns total time of the motion
111
+
102
112
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
+
108
120
>>> total_time(30, 45)
109
121
4.33
110
122
>>> total_time(100, 78)
@@ -125,6 +137,8 @@ def total_time(init_velocity: float, angle: float) -> float:
125
137
126
138
def test_motion () -> None :
127
139
"""
140
+ Test motion
141
+
128
142
>>> test_motion()
129
143
"""
130
144
v0 , angle = 25 , 20
0 commit comments