Skip to content

Commit

Permalink
Fix sphinx/build_docs warnings for physics/horizontal_projectile_moti…
Browse files Browse the repository at this point in the history
…on (#12467)
  • Loading branch information
MaximSmolskiy authored Dec 24, 2024
1 parent 04fbfd6 commit e9721aa
Showing 1 changed file with 41 additions and 27 deletions.
68 changes: 41 additions & 27 deletions physics/horizontal_projectile_motion.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"""
Horizontal Projectile Motion problem in physics.
This algorithm solves a specific problem in which
the motion starts from the ground as can be seen below:
(v = 0)
* *
* *
* *
* *
* *
* *
GROUND GROUND
the motion starts from the ground as can be seen below::
(v = 0)
* *
* *
* *
* *
* *
* *
GROUND GROUND
For more info: https://en.wikipedia.org/wiki/Projectile_motion
"""

Expand Down Expand Up @@ -43,14 +46,17 @@ def check_args(init_velocity: float, angle: float) -> None:


def horizontal_distance(init_velocity: float, angle: float) -> float:
"""
r"""
Returns the horizontal distance that the object cover
Formula:
v_0^2 * sin(2 * alpha)
---------------------
g
v_0 - initial velocity
alpha - angle
.. 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, 78)
Expand All @@ -70,14 +76,17 @@ def horizontal_distance(init_velocity: float, angle: float) -> float:


def max_height(init_velocity: float, angle: float) -> float:
"""
r"""
Returns the maximum height that the object reach
Formula:
v_0^2 * sin^2(alpha)
--------------------
2g
v_0 - initial velocity
alpha - angle
.. math::
\frac{v_0^2 \cdot \sin^2 (\alpha)}{2 g}
v_0 - \text{initial velocity}
\alpha - \text{angle}
>>> max_height(30, 45)
22.94
>>> max_height(100, 78)
Expand All @@ -97,14 +106,17 @@ def max_height(init_velocity: float, angle: float) -> float:


def total_time(init_velocity: float, angle: float) -> float:
"""
r"""
Returns total time of the motion
Formula:
2 * v_0 * sin(alpha)
--------------------
g
v_0 - initial velocity
alpha - angle
.. 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)
Expand All @@ -125,6 +137,8 @@ def total_time(init_velocity: float, angle: float) -> float:

def test_motion() -> None:
"""
Test motion
>>> test_motion()
"""
v0, angle = 25, 20
Expand Down

0 comments on commit e9721aa

Please sign in to comment.