#include #include#include
using namespacestd;structPoint2
{doublex;doubley;
Point2(int px, int py) { x = px; y =py; }
};
Point2 P0(100, 200);
Point2 P1(350, 200);
Point2 derP0(200, 200);
Point2 derP1(200, 200);bool mouseLeftDown = false;bool mouseRightDown = false;/*计算Hermite曲线*/
void Hermit(intn)
{floatf1, f2, f3, f4;double deltaT = 1.0 /n;
glBegin(GL_LINE_STRIP);for (int i = 0; i <= n; i++) {double T = i *deltaT;
f1= 2.0*pow(T, 3) - 3.0*pow(T, 2) + 1.0;
f2= -2.0*pow(T, 3) + 3.0*pow(T, 2);
f3= pow(T, 3) - 2.0*pow(T, 2) +T;
f4= pow(T, 3) - pow(T, 2);
glVertex2f(f1*P0.x + f2*P1.x + f3*derP0.x + f4*derP1.x,
f1*P0.y + f2*P1.y + f3*derP0.y + f4*derP1.y);
}
glEnd();
}/*用鼠标进行绘制,完成