From 65c3e8736a18c144e575de244afe9e38431ffe09 Mon Sep 17 00:00:00 2001 From: Taha Belkhiri <belkhiri.taha53@gmail.com> Date: Tue, 28 Jun 2022 13:15:12 +0200 Subject: [PATCH] ajout fonction trajectoire --- .../antoi_render_2d/source/ball.c | 11 ++++++++++- .../antoi_render_2d/source/render.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/ball.c b/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/ball.c index f7961b4..9f4f031 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/ball.c +++ b/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/ball.c @@ -9,6 +9,12 @@ void initBall (){ } + +double f(int x, float xc, float yc, float xf, float yf, float xt, float yt){ + double returnValue = yf * ((x - xc)/(xf - xc)) * ((x - xt)/(xf - xt)) + yc * ((x - xf)/(xc - xf)) * ((x - xt)/(xc - xt)) + yt * ((x - xc)/(xt - xc)) * ((x - xf)/(xt - xf)); + return returnValue; +} + void laGrange (float beta[3],float Z[3]){ // y , x printf("x canon : %f, x chute : %f, x filet : %f\n", Z[0], Z[1], Z[2]); printf("y canon : %f, y chute : %f, y filet : %f\n", beta[0], beta[1], beta[2]); @@ -43,6 +49,9 @@ void calculationTrajectory(canon_t canon, int xDropPoint, int yDropPoint){ float setUp[2][3]; float distance= (float)(yDropPoint-canon.y); + + printf("test : %f\n", y); + trajectory[0][0]=canon.y; trajectory[0][1]=canon.x; @@ -70,7 +79,7 @@ void calculationTrajectory(canon_t canon, int xDropPoint, int yDropPoint){ laGrange(setUp[1],setUp[0]); //laGrange(y, x); - printf("coef a:%f; coef b:%f; coef c:%f\n", coefLagrange.a, coefLagrange.b, coefLagrange.c); + //printf("coef a:%f; coef b:%f; coef c:%f\n", coefLagrange.a, coefLagrange.b, coefLagrange.c); float step= distance / (NUMBERPOINT-1); diff --git a/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/render.c b/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/render.c index 8bfa931..0a68238 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/render.c +++ b/travail_de_groupe/jeu_appren_par_renfo/antoi_render_2d/source/render.c @@ -251,7 +251,7 @@ void drawTrajectoireSideView(){ ); for(int i=0; i<NUMBERPOINT-1; i++){ - printf("point %d (%d, %d)\n", i, trajectory[i][0], trajectory[i][1]); + //printf("point %d (%d, %d)\n", i, trajectory[i][0], trajectory[i][1]); SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255); SDL_RenderDrawLine(renderer, trajectory[i][0], trajectory[i][1], trajectory[i+1][0], trajectory[i+1][1]); } -- GitLab