# Rotation of Rectangle along Y-axis transformed to parallelogram

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:

Original rectangle:

Not using the openGl, ViewProperty animator is used!

-
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

## 1 Answer

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: http://www.facstaff.bucknell.edu/mastascu/elessonsHTML/Circuit/MatVecMultiply.htm

This gives a nice explanation of the OpenGL pipeline: http://www.songho.ca/opengl/gl_transform.html

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

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