How can I draw this mathematical function
f(x) = e^-x(cos(2(3.14285714)x))
int num = ???;
float start = ???;
float end = ???;
float dx = (end - start) / num;
Begin(POINTS);
for(int i = 0; i <= num; i++)
{
float x = start + i*dx;
float fx = exp(-x * cos(2*3.14285714*x));
Vertex2f(x, fx);
}
End();
it’s sloppy, but should work if you setup your modelview and projection properly.
And I found it nicer to use GL_LINES instead of GL_POINTS.
here here, lines are much nicer, less pointy.