How to create and print Lagrange polynomial in Visual C++ with using OpenGL library? Thanks a lot.开发者_如何转开发
There could be different approaches but guess one of the most simple to understand approaches might be something like this:
float f(float x)
{
// calculate y for f(x) here
return y;
}
void draw()
{
glBegin();
for(float x = 0; x < 10; x += 0.1)
glVertex(x, f(x), 0);
glEnd();
}
Please note that there are different ways to draw the graph (e.g. caching everything or passing an array etc.) with different performance culprits and advantages. In my example scaling etc. have to be done outside using view and projection matrix.
精彩评论