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 & HelpPrograms › 3D vector rotation to Euler Angles
Page Index Toggle Pages: 1
3D vector rotation to Euler Angles (Read 1390 times)
3D vector rotation to Euler Angles
Feb 12th, 2007, 9:12pm
 
Hi happy coders

I am trying to write my own 3D vector class and I need to do as follows:

Vect3 tmpVect = new Vect3( 4, 9, 2 );
print( tmpVect.angleX() + ", ");
print( tmpVect.angleY()  + ", ");
print( tmpVect.angleZ() );

I spend a lot of time googl'ing for help on this, but it seems to be harder than I first thought. As I understand, not even Daniels Shiffman's 'noc' library can return euler angles from each axis on a rotated 3D vector. Am I missing somthing important?

Thanks
Carl Emil
Re: 3D vector rotation to Euler Angles
Reply #1 - Feb 14th, 2007, 12:35am
 
hej carl

firstofall, it might sound a bit patronizing, but there are quite a lot of really cool vector libraries out there. why not use one of them and spend your time on other things ;)

but if you really want to get your hands dirty, which i always understand, you should read this document:

The Matrix and Quaternions FAQ

most of what i know about linear algebra i learned from this one. you should definitely read about matrices and even quaternions.

Carl_Email wrote on Feb 12th, 2007, 9:12pm:
Vect3 tmpVect = new Vect3( 4, 9, 2 );
print( tmpVect.angleX() + ", ");
print( tmpVect.angleY()  + ", ");
print( tmpVect.angleZ() );

the misconception with your question is that there is no single direct relation between euler angels and vectors. it is called the gimbal lock. in other words, the order in which you apply angles matters very much.

but if you just want to find the rotation of single components you can always use the 'atan2' method. but that s probably not what you where asking for.

cheers
d3
Re: 3D vector rotation to Euler Angles
Reply #2 - Feb 14th, 2007, 3:27am
 
Dennis! =)

Yeah, you're right I spend a lot of time reinventing the wheel. It's an exchange of productivity for knowledge that I think a lot about keeping in balance.

The link is great. It answers my question very precisely. It might take me more than five minutes to consume though.

Thanks.

Caught in the gimbal lock
Carl Emil
Page Index Toggle Pages: 1