physics.horizontal_projectile_motion ==================================== .. py:module:: physics.horizontal_projectile_motion .. autoapi-nested-parse:: 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 For more info: https://en.wikipedia.org/wiki/Projectile_motion Attributes ---------- .. autoapisummary:: physics.horizontal_projectile_motion.g physics.horizontal_projectile_motion.init_vel Functions --------- .. autoapisummary:: physics.horizontal_projectile_motion.check_args physics.horizontal_projectile_motion.horizontal_distance physics.horizontal_projectile_motion.max_height physics.horizontal_projectile_motion.test_motion physics.horizontal_projectile_motion.total_time Module Contents --------------- .. py:function:: check_args(init_velocity: float, angle: float) -> None Check that the arguments are valid .. py:function:: horizontal_distance(init_velocity: float, angle: float) -> float 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, 78) 414.76 >>> horizontal_distance(-1, 20) Traceback (most recent call last): ... ValueError: Invalid velocity. Should be a positive number. >>> horizontal_distance(30, -20) Traceback (most recent call last): ... ValueError: Invalid angle. Range is 1-90 degrees. .. py:function:: max_height(init_velocity: float, angle: float) -> float Returns the maximum height that the object reach Formula: .. 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) 487.82 >>> max_height("a", 20) Traceback (most recent call last): ... TypeError: Invalid velocity. Should be a positive number. >>> horizontal_distance(30, "b") Traceback (most recent call last): ... TypeError: Invalid angle. Range is 1-90 degrees. .. py:function:: test_motion() -> None Test motion >>> test_motion() .. py:function:: total_time(init_velocity: float, angle: float) -> float 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, 40) Traceback (most recent call last): ... ValueError: Invalid velocity. Should be a positive number. >>> total_time(30, "b") Traceback (most recent call last): ... TypeError: Invalid angle. Range is 1-90 degrees. .. py:data:: g :value: 9.80665 .. py:data:: init_vel