calculate angles from corrdinates

Started by
10 comments, last by RPTD 19 years, 3 months ago
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.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

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
stop picking your nose
heading can be found by atan2( direction.x, directions.z )
needs to be normalized first (without the y component)
heading works... got that one too... but! not always. i found a couple of singularity problems where this simple technic will not work.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

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-
- a human beyond the bug -
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).

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

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-
- a human beyond the bug -
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.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

That's true :)
But I didn't get the "just with translation included but this should not be the problem i guess".
-uto-
- a human beyond the bug -
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.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

This topic is closed to new replies.

Advertisement