1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
std::vector<XY> liste_pts;// j'ai mis en global c'est pas beau
XY CalcBezier(double t)
{
int i;
XY p;
for(i=0;i<liste_pts.size();i++)
{
p.x+=Berstein(i, l.nbCtrlPoints, t)*liste_pts[i].x;
p.y+=Berstein(i, l.nbCtrlPoints, t)*liste_pts[i].y;
}
return p;
}
///.........
void display(void)
{
struct XY p1, p2, p3, p4;
CtrlPoints l;
p1.x=-4.0;
p1.y=-4.0;
p2.x=-2.0;
p2.y=4.0;
p3.x=2.0;
p3.y=-4.0;
p4.x=4.0;
p4.y=4.0;
liste_pts.push_back(p1);
liste_pts.push_back(p2);
liste_pts.push_back(p3);
liste_pts.push_back(p4);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glPointSize(5.0);
glColor3f(1.0, 1.0, 0.0);
glFlush();
} |
Partager