• Advertisement
Sign in to follow this  

calculate angles from corrdinates

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

for my mapeditor i want the user to be able to freely rotate multiple objects at once. for that i need to calculate after the rotation what euclidean angles they are representing (or rather, which set of eucledian angles gives the wished result). now after filling couple of sheets with calculations i still didn't find a way to get those three angles if i can provide a view and an up vector (obtained by rotating those two with the objects together). can i do this somewhat correct and simple with euclidean angles? or do i need quaternions? i heard quaternions are powerfull but incredibly difficult to work with.

Share this post


Link to post
Share on other sites
Advertisement
yeh i need to know this too.
i thought all i had to do was put the new axi into a view transform and presto it works.
if someone can help here it would be extremely useful

Share this post


Link to post
Share on other sites
heading can be found by atan2( direction.x, directions.z )
needs to be normalized first (without the y component)

Share this post


Link to post
Share on other sites
heading works... got that one too... but! not always. i found a couple of singularity problems where this simple technic will not work.

Share this post


Link to post
Share on other sites
I'm not sure to understand exactly your problem but tell me if I am wrong,
You have a selection of several 3D objects and you want to apply a rotation the selection and then recover the euler angles of the final orientation of each object.

For that you need a kind of pivot arround which the rotation is performed. That means that the objects will not only rotate but translated as well.
Considere that every object is associated to a transformation <R | T> (R : rotation, T : translation> (no matter if R is a matrix or quaternion or whaterver)
So if your pivot is at the 3D position Pp, and you want to apply the rotation Rs to you selection, for every object :

<R'|T'> = <Rs*R | Rs*(T-Pp)+ Pp>

Then from R'you want to recover the euler angles, but for that you need to choose a convention about how you want to consider your rotation :
For each rotation R you have 3 way to decompose it as a composition of 3 rotations :

R = Rx*Ry*Rz
R = Ry*Rx*Rz
R = Rz*Ry*Rx

(Rx*Ry*Rz means first rotate arround z then arround y then arround x)

from this point whatever is your rotation (rotation or quaternion) you can find easily in the litterature or the web the decomposition functions you need.

Personnally I like to deal with quaternion, but there is some pros and cons, it depend to what you want and what you expect.


-uto-

Share this post


Link to post
Share on other sites
can you quickly outline the pros and cons of quaternions?

in fact knowing how to get euler angles back from quaternions (which would be one step in the entire process) would help me too in building an export plugin for Blender3D (which stores bone rotations as quaternions).

Share this post


Link to post
Share on other sites
One says that it's not that efficient to use quaternion, and the main interest is for the rotation interpolation. The main cons (according of what I am doing with) for the quaternion is for the camera manipulation that might be tricky in some case to lock the roll.
http://www.gamedev.net/community/forums/topic.asp?topic_id=287319

Then, if you want to convert quaternion to euler angles, a simple way is to convert a quaternion to a rotation matrix, and the to extract the euler angle from the matrix.

here (http://www.magic-software.com/Math.html) you have a bunch of classes and code that perfoms all what is needed.

-uto-

Share this post


Link to post
Share on other sites
you say a rotation matrix is enough to get the euler angles back from right? thus a matrix would be much easier than the other formula? if i got already view and up vector i got already the rotation matrix... just with translation included but this should not be the problem i guess.

Share this post


Link to post
Share on other sites
That's true :)
But I didn't get the "just with translation included but this should not be the problem i guess".
-uto-

Share this post


Link to post
Share on other sites
a pure rotation matrix is not allowed to have translation. for example a normal can only be directly transformed with a pure rotation matrix. otherwise you need to fix the result. that's what i mean with it.

Share this post


Link to post
Share on other sites
Quote:
Original post by RPTD
heading works... got that one too... but! not always. i found a couple of singularity problems where this simple technic will not work.


it should work everytime.
perhaps youre not ignoring the y component of the vector
eg vector.y = 0.0;
then normalize the vector after it (important)
atan2(x,z) gives the result in radians from -PI -> PI

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement