# Thread: Coordinate system question

1. ## Coordinate system question

How do I retrieve, or set the visible coordinate system of a perspective volume?

I know how to map the x,y on an ortho volume to the window's x,y, but is there a way to do this for perspective volumes?

Hmm, is it just me or do I seem vague here?

What I'm trying to do is find out what the ratio is between 1.0 units in the x or y direction on a given plane x,y along the z axis in relation to the window coordinates.

ie: the right-most edge of the window is, say, 400 pixels. I want to know what that is in volume units 200 units back into the viewing volume. I know it will be much bigger than 400.

Siwko

2. ## Re: Coordinate system question

As long as you have access to the viewing matrix (GL_MODELVIEW) and projection matrix (GL_PROJECTION), you can use the "gluProject" function (part of the GLU library). You pass in your object coordinates (x,y,z), model view matrix, projection matrix, and viewport extents. The function returns the window (x,y,z).

Originally posted by Siwko:
How do I retrieve, or set the visible coordinate system of a perspective volume?

I know how to map the x,y on an ortho volume to the window's x,y, but is there a way to do this for perspective volumes?

Hmm, is it just me or do I seem vague here?

What I'm trying to do is find out what the ratio is between 1.0 units in the x or y direction on a given plane x,y along the z axis in relation to the window coordinates.

ie: the right-most edge of the window is, say, 400 pixels. I want to know what that is in volume units 200 units back into the viewing volume. I know it will be much bigger than 400.

Siwko

3. ## Re: Coordinate system question

When (if) you set your frustum with glFrustum(l, r, b, t, n, f), you can use these values to calculate how much a unit on the y (or x)-axix at z=<anything> is worth on the viewport. A hint: the point <l,b,n> is the point on the near clippingplane that will be projected on the bottom left corner of the viewport, and <r,t,f> is the point on the far plane that will be projected on the top right corner of the viewport.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•