diff --git a/argparser.c b/argparser.c index d56a555..9619fd3 100644 --- a/argparser.c +++ b/argparser.c @@ -3,7 +3,7 @@ #include "argparser.h" void usage() { - printf("Cosmology: -c [--debug]\n"); + printf("Astrophysics: [--debug]\n"); } int getArgs(char *arg) { @@ -11,7 +11,7 @@ int getArgs(char *arg) { int i; /* List arguments */ char listArgs[3][BUF_SIZE]; - strcpy(listArgs[0], "-c"); // Gravity + strcpy(listArgs[0], "-p"); // Projectile for(i = 0; i < 3; i++){ if(strcmp(listArgs[i], arg) == 0) diff --git a/main b/main index afdcb7f..8d0589a 100755 Binary files a/main and b/main differ diff --git a/main.c b/main.c index 5167d3a..c94a7f0 100644 --- a/main.c +++ b/main.c @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) { mainInitProjectile(yamlFile, &s_projectile, s_planet1.grav); switch (argv[1][1]){ - case 'c': + case 'p': handleProjectile(&s_projectile, &s_planet1, debug); break; default: @@ -113,8 +113,8 @@ static void mainInitProjectile(const struct yamlFile *yamlFile, struct projectil s_projectile->masse = parseYamlFileInt(yamlFile, "Projectile:masse"); s_projectile->alpha = parseYamlFileDouble(yamlFile, "Projectile:angle"); deg_to_rad = degree_to_radian(s_projectile->alpha); - s_projectile->v0x = calcul_initial_speed(deg_to_rad, v0, 'x'); - s_projectile->v0y = calcul_initial_speed(deg_to_rad, v0, 'y'); + s_projectile->v0x = calculate_initial_speed(deg_to_rad, v0, 'x'); + s_projectile->v0y = calculate_initial_speed(deg_to_rad, v0, 'y'); s_projectile->rect.x = s_projectile->x; s_projectile->rect.y = s_projectile->y; s_projectile->rect.w = s_projectile->height; @@ -122,11 +122,11 @@ static void mainInitProjectile(const struct yamlFile *yamlFile, struct projectil /***** Informations about the projectile *****/ // Calcul delta t - s_projectile->deltat = calcul_delta_t(s_projectile->v0y, grav); + s_projectile->deltat = calculate_delta_t(s_projectile->v0y, grav); // calcul distance in meter - s_projectile->distance = calcul_distance_total(s_projectile->v0x, s_projectile->deltat); + s_projectile->distance = calculate_total_distance(s_projectile->v0x, s_projectile->deltat); // Calcul height Max - s_projectile->hmax = calcul_height_max(0.0, s_projectile->v0y, grav); + s_projectile->hmax = calculate_height_max(0.0, s_projectile->v0y, grav); } diff --git a/motion.c b/motion.c index 8aa7ec0..7883791 100644 --- a/motion.c +++ b/motion.c @@ -1,35 +1,47 @@ #include "motion.h" #include -double calcul_initial_speed(double alpha, double speed, const char c) { - // We calculated the v0 of y +/* + * Here, we calculate the initial speed + * Where alpha is the initial launch angle + * speed is the initial speed + * and c defined if we calculate for x or y + */ +double calculate_initial_speed(double alpha, double speed, const char c) { + // We calculated the v0 of x if (c == 'x') return speed * cos(alpha); - // Otherwise, we calculated the v0 of x + // Otherwise, we calculated the v0 of y else return speed * sin(alpha); } /* - * This function calcul the during of the time before the projectile have touche the ground + * This function calcul the during of the time before the projectile have reach the ground + * Where v is the initial speed of xor y + * and grav is the gravitational force */ - double calcul_delta_t(double v, double grav){ + double calculate_delta_t(double v, double grav){ return (2 * v) / grav; } /* * This function calcul the distance total of the projectile + * Where v is the initial speed of Vx + * and deltat is the result total time of flight */ - double calcul_distance_total(double v, double deltat){ + double calculate_total_distance(double v, double deltat){ return v * deltat; } /* * This function calcul the height max of the Projectile + * Where vx and xy are the initial speeds + * and grav is the gravitational force */ - double calcul_height_max(double vx, double vy, double grav){ +double calculate_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; - } +double degree_to_radian(double degree){ + return degree * M_PI / 180; +} diff --git a/motion.h b/motion.h index b99ac0e..ecddd3c 100644 --- a/motion.h +++ b/motion.h @@ -1,10 +1,10 @@ #ifndef H_MOTION #define H_MOTION -double calcul_initial_speed(double, double, const char); -double calcul_delta_t(double, double); -double calcul_distance_total(double, double); -double calcul_height_max(double, double, double); +double calculate_initial_speed(double, double, const char); +double calculate_delta_t(double, double); +double calculate_total_distance(double, double); +double calculate_height_max(double, double, double); double degree_to_radian(double); #endif diff --git a/sdl/projectile.c b/sdl/projectile.c index 5ab20ad..a4420e8 100644 --- a/sdl/projectile.c +++ b/sdl/projectile.c @@ -5,7 +5,7 @@ #include "projectile.h" /* State of projectile */ -int isLaunch; +static int isLaunch; /* * This function initialize our Projectile @@ -174,7 +174,7 @@ void handleProjectile(struct projectile *s_projectile, const struct object *s_pl args.window = s_window; /* Init celestial object */ - *sInfos = TTF_RenderText_Blended(s_window.font, "Earth", colorFont); + *sInfos = TTF_RenderText_Blended(s_window.font, "Ground", colorFont); initInfos(s_window.font, &rectInfos[0], sInfos[0], (WIN_PROJECTILE_WIDTH / 2) - sInfos[0]->w, rectObject.y + 15); /* Get distance and time */