Hi I need help!!

I really need to figures out how to draw this.

http://www.dropshots.com/zoom.html?large=http://media11.dropshots.com/photos/987629/20120313/b_103409.jpg

This is one curve, but it is scaled by a different amount as the angles increase in the loop. The curve also goes through more angles. We see 4 * 360 degrees plotted here.

Here is what I have. But I still need a lot to work on this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <math.h>
#include <GL/glut.h>
#include "Graphics.h"

void drawAxes(void);
void drawSine(void);

void drawScene(void) {
    clearWindow();
    drawAxes();
    drawSine();
    glEnd();
    glFlush();
}

int main(int argc, char ** argv) {
    GraphicsSetup(argc, argv);
    glutDisplayFunc(drawScene);
    glutMainLoop();
}

void drawAxes(void) {
    setColor(BLACK);
    drawLine(250,50,250,450);
    drawLine(0,250,500,250);
}

void drawSine(void) {
    double angle_radians;
    int x, y;
    const double PI = acos(-1.0);
    for(int angle = -360; angle <= 360; angle++) {
        x = (angle + 360) * 500.0/720.0;
        angle_radians = angle * PI / 180.0;
        y = 250 + sin(angle_radians) * 200;
        drawFilledCircle(x,y,2);
    }
}
If you are asking for the equation, it is something like this:

y = A * e-ax * sin(bx)

where A = amplitude, a and b are constants and x is the angle in radians.
And where would I be able to use this in? Or how would it look like inside?
You use that equation to calculate the value of y, which is the vertical component of the dot belonging to the function.
How can I put that as code?


Can anyone help?
Last edited on
Topic archived. No new replies allowed.