We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Calculation of rotation angles for 3D rotation
Page Index Toggle Pages: 1
Calculation of rotation angles for 3D rotation (Read 729 times)
Calculation of rotation angles for 3D rotation
Jul 4th, 2006, 7:47am
 
Hi,
I have plotted a 3D cube on to the screen.
Now I need to rotate that cube on mouse drag event.
Whenever I drag the mouse, the cube should be rotated in X, Y or Z direction as per the movement.
But we have only the X and Y co-ordinates of the movement.
By what angle do I rotate in X, Y direction to give this 3D effect??
Any pointers on calculation of the angle of rotation between 2 points?


Re: Calculation of rotation angles for 3D rotation
Reply #1 - Jul 10th, 2006, 1:28pm
 
Hi

I have tried this in processing using the rotate functions but either I am missing something or the functions are not implemented optimally. This is a quick hack using code I took from Ken Perlins Java 1.1 3D Renderer (http://mrl.nyu.edu/~perlin/experiments/packing/render/index.html)


It would be nice to use the PMatrix class or better yet the rotateX, rotateY functions. Perhaps someone else can help out here.


Hack here -> http://www.fluidforms.at/en/ClickAndRotateHack.php


Tooteloo,
Stephen
Page Index Toggle Pages: 1