Jefft

12-14-2005, 06:25 AM

given a set of x,y coordinates, what is the simplest way to plot the data? I want to be able to just plot the points and then I want to be able to draw a curve through the points. Thanks

View Full Version : help! what's the simplest way to generate an XY plot using openGL/glut?

Jefft

12-14-2005, 06:25 AM

given a set of x,y coordinates, what is the simplest way to plot the data? I want to be able to just plot the points and then I want to be able to draw a curve through the points. Thanks

songho

12-14-2005, 08:31 AM

Jefft,

To plot 2d points you may use glVertex2i(x,y).

glBegin(GL_POINTS);

glVertex2i(x, y);

glEnd();Drawing points very simple like above code, but you are not asking this, do you?

To plot 2d points you may use glVertex2i(x,y).

glBegin(GL_POINTS);

glVertex2i(x, y);

glEnd();Drawing points very simple like above code, but you are not asking this, do you?

Jefft

12-14-2005, 08:57 AM

OK... next question... When I create a window, the origin (0,0) is at the center. All points I need to plot will be in the first quadrant (positive x, positive y). Is there a way to shift the view or something to only show the first quadrant?

Bob

12-14-2005, 09:02 AM

Look up glOrtho. It creates a projection matrix and you can use it map any part of the coordinate system to your window.

songho

12-14-2005, 09:35 AM

If the resolution of your rendering window is 400x300, set your projection matrix with:

gluOrtho2D(0, 400, 0, 300);

This gives you Quadrant 1 only. The origin (0,0) is the lower-left corner and (399,299) would be the top-right corner.

==song==

gluOrtho2D(0, 400, 0, 300);

This gives you Quadrant 1 only. The origin (0,0) is the lower-left corner and (399,299) would be the top-right corner.

==song==

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.