Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

After the rotation of a rectangular view along the Y-axis, about its center, transformed into parallelogram, how do I get the rotated parallelogram coordinates?

By Y-axis, I mean perpendicular to the device screen.

Rotated rectangle:

rectangle rotated 40 degree about its center

Original rectangle:

Non Rotated Image

Not using the openGl, ViewProperty animator is used!

share|improve this question
Are you looking for the screen projected coordinates? – RobCurr Mar 3 '13 at 21:51
@RobCurr Yes! formula to calculate projected figure co-ordinates – Unknown Mar 4 '13 at 3:27
not an opengl guy but I beleive you need to use gluProject() with your current projection, view, viewport and screen dimensions for each of the 4 points. – RobCurr Mar 4 '13 at 6:44

First of all the resulting shape is not a parallelogram but a trapezoid. From what you write I gather that you are using the fixed-function pipeline rather than the programmable pipeline (which makes the solution really quite obvious). Basically what you need to do is perform the processing of the vertices again the same way as OpenGL does. This is the only way I could think of. If you now a better one let me now. You can use glGet to retrieve your modelview and your projection matrices and than apply them to your coordinate vector. This would leave you with the coordinates in clip space. You can than perform the division by W to get normalized device coordinates. Than perform the viewport transform to end up with window coordinates. I guess these are the coordinates you want. Alternatively you could also loop through the framebuffer and scan for colour changes. This would be a far less efficient way.

This explains nicely on how to multiply a matrix and a vector:

This gives a nice explanation of the OpenGL pipeline:

EDIT: This appears to be exactly what the function gluProject does.

share|improve this answer
Well 'm not using opengl directly. I use ViewProperty animator to rotate the view. – Unknown Mar 4 '13 at 9:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.