I'd like to know how can I use these functions to generate curves in OpenGL:
x(t) = sin(t) + 1/2 sin(5t) + 1/4 cos(2,3t)
y(t) = cos(t) + 1/2 cos(5t) + 1/4 sin(2,3t)
It's a college exercise, I've done something with circles, but with curves I'm having problems.
I didn't catch the way for building curves, I've tried to build a code to generate a simple curve to see how It works, but It's completly wrong because It generated something very strange. I'd like to see a simple example of a curve with this function to understanding how I must start to construct the draw like the prints.
Test code:
void exerciseTwo(){
write("Exercise Two", -5, 18);
float x = 0, y = 0, t =0;
glPushMatrix();
glBegin(GL_LINE_STRIP);
for(t = -10.0; t < 10.0; t += 0.1){
x = sin(t) + ((1/2) * sin(5 * t)) + ((1/4) * cos(2.3 * t));
glVertex2f(x, t);
}
for(t = -10.0; t < 10.0; t += 0.1){
y = cos(t) + ((1/2) * cos(5 * t)) + ((1/4) * sin(2.3 * t));
glVertex2f(t, y);
}
glEnd();
glPopMatrix();
write("Press 0 (zero) to come back.", -10, -18);
}
Am I in the right way or not?