# Thread: how to get the vertices coordinates

1. ## how to get the vertices coordinates

Hi,i am new to computer graphic
I want to know this:
If i have view matrix and projection matrix,and can i know the vertex coordinates of say,at the center of my viewport or the top-left of my viewport?Thank guys~

2. ## Re: how to get the vertices coordinates

If i have view matrix and projection matrix,and can i know the vertex coordinates of say,at the center of my viewport or the top-left of my viewport
Are you talking about a 3D projection or a 2D orthographic projection?
For 2D, it's much easier, for 3D it's not an easy thing.

Why do you need to do this? What makes you think this is something useful to you?

3. ## Re: how to get the vertices coordinates

Since the screen coordinates are calculated using the following equation:

V_screen = M_Viewport * M_Projection * M_ModelView * V_local

then, the local coordinates (coordinates in the model-space), can be easily calculated using the following formula:

V_local = M_ModelView ^ -1 * M_Projection ^ -1 * M_Viewport ^ -1 * V_screen

where:

M_Viewport - viewport transformation matrix,
M_Projection - projection matrix,
M_ModelView - model-view matrix
V_local - vertex spatial coordinates in object-space
V_screen - vertex coordinates in screen-space

You just have to retrieve screen coordinates (X,Y) and the depth (Z-coordinate) of the clicked pixel. This assumes the pixel is visible, or otherwise it would be difficult to read the depth. Also, clicking a pixel on the screen does not assumes that you have clicked a vertex. You probably want to implement some kind of picking.

4. ## Re: how to get the vertices coordinates

Originally Posted by Aleksandar
Since the screen coordinates are calculated using the following equation:

V_screen = M_Viewport * M_Projection * M_ModelView * V_local
Don't forget the perspective divide:

* OpenGL Transformation (songho)

Clipping happens right before this.

#### Posting Permissions

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