Vusi

06-09-2004, 01:09 PM

How can I draw this mathematical function

f(x) = e^-x(cos(2(3.14285714)x))

f(x) = e^-x(cos(2(3.14285714)x))

View Full Version : Help!!!....How to draw curves using dot plots

Vusi

06-09-2004, 01:09 PM

How can I draw this mathematical function

f(x) = e^-x(cos(2(3.14285714)x))

f(x) = e^-x(cos(2(3.14285714)x))

06-09-2004, 08:35 PM

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.

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.

ZbuffeR

06-09-2004, 11:57 PM

And I found it nicer to use GL_LINES instead of GL_POINTS.

06-12-2004, 08:21 PM

here here, lines are much nicer, less pointy.

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.