Rotation on Z Axis

28 views
Skip to first unread message

Sergi Martínez

unread,
Apr 17, 2012, 5:03:35 AM4/17/12
to app...@googlegroups.com
Hi

I've fixed the issue on the Z Axis. Recap:

The calculations taken from wikipedia (http://en.wikipedia.org/wiki/3D_projection#Perspective_projection) were ok for the  X and Y axis, but the Z axis was applied to the whole universe  instead to the view.

What I did is:

Calculate position of the point on screen using X, Y and a fix Z (value 0 or PI/2, depending on phone rotation). So, all points are calculated in space parallel to horizon.

Then, once the screenX and screenY are calculated, just use a 2d rotation around the centre of the screen using the formulas on  http://en.wikipedia.org/wiki/Rotation_(mathematics) 

And voila!

Just needs ajust on how to apply depending on the rotation, but that's just minor stuff.

--

Sergi Martínez


sergi.m...@gmail.com
Reply all
Reply to author
Forward
0 new messages