TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Ground to ground projectile motion equation implementations. More...
#include <cassert>
#include <cmath>
#include <iostream>
Go to the source code of this file.
Namespaces | |
namespace | physics |
for IO operations | |
namespace | ground_to_ground_projectile_motion |
Functions for the Ground to ground projectile motion equation. | |
Macros | |
#define | _USE_MATH_DEFINES |
for assert() | |
Functions | |
double | physics::ground_to_ground_projectile_motion::degrees_to_radians (double degrees) |
Convert radians to degrees. | |
template<typename T > | |
T | physics::ground_to_ground_projectile_motion::time_of_flight (T initial_velocity, T angle, double gravity=9.81) |
Calculate the time of flight. | |
template<typename T > | |
T | physics::ground_to_ground_projectile_motion::horizontal_range (T initial_velocity, T angle, T time) |
Calculate the horizontal distance that the projectile travels. | |
template<typename T > | |
T | physics::ground_to_ground_projectile_motion::max_height (T initial_velocity, T angle, double gravity=9.81) |
Calculate the max height of the projectile. | |
static void | test () |
Self-test implementations. | |
int | main () |
Main function. | |
Ground to ground projectile motion equation implementations.
Ground to ground projectile motion is when a projectile's trajectory starts at the ground, reaches the apex, then falls back on the ground.
Definition in file ground_to_ground_projectile_motion.cpp.
#define _USE_MATH_DEFINES |
for assert()
Definition at line 13 of file ground_to_ground_projectile_motion.cpp.
double physics::ground_to_ground_projectile_motion::degrees_to_radians | ( | double | degrees | ) |
Convert radians to degrees.
radian | Angle in radians |
Definition at line 34 of file ground_to_ground_projectile_motion.cpp.
T physics::ground_to_ground_projectile_motion::horizontal_range | ( | T | initial_velocity, |
T | angle, | ||
T | time ) |
Calculate the horizontal distance that the projectile travels.
initial_velocity | The starting velocity of the projectile |
time | The time that the projectile is in the air |
Definition at line 59 of file ground_to_ground_projectile_motion.cpp.
int main | ( | void | ) |
Main function.
Definition at line 138 of file ground_to_ground_projectile_motion.cpp.
T physics::ground_to_ground_projectile_motion::max_height | ( | T | initial_velocity, |
T | angle, | ||
double | gravity = 9.81 ) |
Calculate the max height of the projectile.
initial_velocity | The starting velocity of the projectile |
angle | The angle that the projectile is launched at in degrees |
gravity | The value used for the gravity constant |
Definition at line 72 of file ground_to_ground_projectile_motion.cpp.
|
static |
Self-test implementations.
Definition at line 83 of file ground_to_ground_projectile_motion.cpp.
T physics::ground_to_ground_projectile_motion::time_of_flight | ( | T | initial_velocity, |
T | angle, | ||
double | gravity = 9.81 ) |
Calculate the time of flight.
initial_velocity | The starting velocity of the projectile |
angle | The angle that the projectile is launched at in degrees |
gravity | The value used for the gravity constant |
Definition at line 47 of file ground_to_ground_projectile_motion.cpp.