From 434be3a1ea96e680591fdf096646f16e951f0bb7 Mon Sep 17 00:00:00 2001 From: Theo Date: Mon, 9 Sep 2024 11:07:52 +0200 Subject: [PATCH] =?UTF-8?q?[2.6=20~]=20Axes=20OK,=20Histo=20TODO=20?= =?UTF-8?q?=F0=9F=95=B7=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.c | 26 +++++++++++++++++++++++++- valeurs.txt | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 32dc62e..888fa32 100644 --- a/main.c +++ b/main.c @@ -14,6 +14,7 @@ void printCourbeTerminal(void); void ligne(int, float, float, float, float); float map(float, float, float, float, float); void reshapeCallback(int, int); +void axes(float, float, float, float); // Variables donneés #define MAXC 20 @@ -40,6 +41,21 @@ float map(float smin, float smax, float val, float omin, float omax) return (omax-omin) * percent + omin; } +void axes(float x1, float x2, float y1, float y2) +{ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0); + glColor3f(1.0,0.5,0.5); + glBegin(GL_LINE_STRIP); + + glVertex2f(x1, y2); + glVertex2f(x2, y2); + glVertex2f(x2, y1); + + glEnd(); +} + void ligne(int index, float hgx, float hgy, float bdx, float bdy) { if(index >= nc) @@ -75,6 +91,14 @@ void ligne(int index, float hgx, float hgy, float bdx, float bdy) fflush(stdout); glEnd(); + + for(unsigned int i = 1; i < size+1; i++) + { + float pos_x = map(0, size-1, i-1, hgx, bdx); + float pos_y = map(valmin[index], valmax[index], courbe[index][i], bdy, hgy); + axes(hgx, pos_x, bdy, pos_y); + } + } void afficher(void) @@ -254,7 +278,7 @@ int main(int argc, char* argv[]) printCourbeTerminal(); - mode_affichage = SUPERPOSER; + mode_affichage = HORIZONTAL; int window = initWindow(argc, argv, afficher); glutMainLoop(); diff --git a/valeurs.txt b/valeurs.txt index 55139ed..5e3f188 100644 --- a/valeurs.txt +++ b/valeurs.txt @@ -1,4 +1,4 @@ -6 +1 45 0.978147601 0.913545458 0.809016994 0.669130606 0.5 0.309016994 0.104528463 -0.104528463 -0.309016994 -0.5 -0.669130606 -0.809016994 -0.913545458 -0.978147601 -1 -0.978147601 -0.913545458 -0.809016994 -0.669130606 -0.5 -0.309016994 -0.104528463 0.104528463 0.309016994 0.5 0.669130606 0.809016994 0.913545458 0.978147601 1 0.978147601 0.913545458 0.809016994 0.669130606 0.5 0.309016994 0.104528463 -0.104528463 -0.309016994 -0.5 -0.669130606 -0.809016994 -0.913545458 -0.978147601 -1 5 1 2 3 4 5 6 21 543.3 75 34 76 89