[2.6 ~] Axes OK, Histo TODO 🕷️

This commit is contained in:
Theo 2024-09-09 11:07:52 +02:00
parent af614ebf4f
commit 434be3a1ea
2 changed files with 26 additions and 2 deletions

26
main.c
View File

@ -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();

View File

@ -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