Plotting Functions Using Dot Plots

I am trying to plot a simple function, but am getting confused as how to write in the different vertexes. The function is:
f(x)=10-100cos((2*pi*x)/50) + 30cos((4*pi*x)/50) +6cos((6*pi*x/50)


I have a general source (posted below) and supposedly it is very simple and all I have to change is the numbers, I am very confused though, how do I find the points to list out of that equation? (like the Xs' & the Ys'- do I work it out? or somehow just post the equation in place of that?) Thanks so much!!! I am really trying to learn and understand


:: Original source ::

#include <windows.h> // use as needed for your system
#include <gl/Gl.h>
#include <gl/glu.h>
#include <gl/glut.h>

//<<<<<<<<<<<<<<<<<<<<<<< myInit >>>>>>>>>>>>>>>>>>>>
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0); // set the bg color to a bright white
glColor3f(0.0f, 0.0f, 0.0f); // set the drawing color to black
glPointSize(4.0); //set the point size to 4 by 4 pixels
glMatrixMode(GL_PROJECTION);// set up appropriate matrices- to be explained
glLoadIdentity();// to be explained
gluOrtho2D(0.0, 640.0, 0.0, 480.0);// to be explained
}

//<<<<<<<<<<<<<<<<<<<<<<<< myDisplay >>>>>>>>>>>>>>>>>
// the redraw function
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT); // clear the screen
glBegin(GL_POINTS);
glVertex2i(100, 50); // draw some points (don't know how many)
glVertex2i(100, 130);
glVertex2i(150, 130);
glEnd();
glFlush(); // send all output to display
}
//<<<<<<<<<<<<<<<<<<<<<<<< main >>>>>>>>>>>>>>>>>>>>>>
void main(int argc, char **argv)
{
glutInit(&argc, argv); // initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set the display mode
glutInitWindowSize(640,480); // set the window size
glutInitWindowPosition(100, 150); // set the window position on the screen
glutCreateWindow("my first attempt"); // open the screen window(with its exciting title)
glutDisplayFunc(myDisplay); // register the redraw function
myInit();
glutMainLoop(); // go into a perpetual loop
}
Topic archived. No new replies allowed.