# Get euler angles from vector?

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I was wondering if anyone knew how to figure out the euler angles required to rotate a vector to it's current position. In other words, take a vector and return its euler angles? Thanks. [Edited by - honayboyz on August 17, 2005 2:25:50 PM]

##### Share on other sites
Probably the easiest way to get the Euler angles from building blocks is to take a quaternion that represents the cross product between the previous and current position and then decompose that quaternion into Euler angles. Most quaternion libraries oriented for use in games should have the primitives necessary to do these operations.

##### Share on other sites
I use this code - ok if you don't need the roll...
(note: angles are in OpenGL-speak)

// Converts a 3d vector into heading and pitch (roll is indeterminate).void NUtils::HdgPitchFromVector3(const TVector3& aDirn, float& aHdg, float& aPitch){	_ASSERT(aDirn.IsNormalised());	aHdg   = -float(RADTODEG * atan2(aDirn.x, -aDirn.z));	aPitch = float(RADTODEG * atan2(aDirn.y, sqrt((aDirn.x*aDirn.x) + (aDirn.z*aDirn.z))));	WrapAngle360(aHdg);}

##### Share on other sites
you can do this by calculating the opposite of sin and cos.

x of a vector is sin of some angle.. and cos is Y of that angle..

1. 1
Rutin
34
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
633337
• Total Posts
3011415
• ### Who's Online (See full list)

There are no registered users currently online

×