Astrophysics/motion.c
2023-08-04 10:39:16 +02:00

36 lines
909 B
C

#include "motion.h"
#include <math.h>
double calcul_initial_speed(double alpha, double speed, const char c) {
// We calculated the v0 of y
if (c == 'x')
return speed * cos(alpha);
// Otherwise, we calculated the v0 of x
else
return speed * sin(alpha);
}
/*
* This function calcul the during of the time before the projectile have touche the ground
*/
double calcul_delta_t(double v, double grav){
return (2 * v) / grav;
}
/*
* This function calcul the distance total of the projectile
*/
double calcul_distance_total(double v, double deltat){
return v * deltat;
}
/*
* This function calcul the height max of the Projectile
*/
double calcul_height_max(double vx, double vy, double grav){
return (pow(vx, 2) - pow(vy, 2)) / (2 * -grav);
}
/*
* This function convert the degree in radian
*/
double degree_to_radian(double degree){
return degree * M_PI / 180;
}