Sign in to follow this  
Dario1986

Help! Extracting angles from a rot Matrix, or quaternion?

Recommended Posts

Dario1986    145
Hello people,

First of all, i say i'm new here but i have been reading you for many years. I'm not used to ask for help but this time I really need it. Let's see.

I'm building a tool where - among other things - you can create a segment of frames for a model where you give a StartFrame and an end Frame as input. The animation segment as you all know is done calling the SLERP function. The problem is easy, I need to get back the set of angles from each of the interpolated frames created seeing that my tool needs to save these values to a file.
I have tried many things, one of them was getting back the Euler angles, but this has many restrictions like the Gimbal Lock and the range of Pitch (x) that goes from -90 to 90.
I was thinking that the function D3DXQuaternionAxisAngle, gives you the axis direction and one angle, so, is it possible to extract some kind of data from this two parameters??

I'm about to finish my tool, but i'm stucked in this issue. I come working on this same problem since the past week and couldn't find a solution. I have seen tools were this was implemented, so I if one of you can raise me a help, I would be really happy!

Keep coding!

PS: I use Directx 8.1 and c++ Builder XE.

Share this post


Link to post
Share on other sites
alh420    5995
What "angles" do you need really?

Or do you mean that you need some kind of representation of the objects orientation(rotation), you can write to file, and don't care what this looks like, as long as you can recreate the orientation later?

Share this post


Link to post
Share on other sites
jjd    2140
I'm not sure if I understand your description but it sounds like you might be looking for a [url="http://en.wikipedia.org/wiki/Polar_decomposition"]polar decomposition[/url].

-Josh Edited by jjd

Share this post


Link to post
Share on other sites
Dario1986    145
Sorry for not answering before, I have some troubles with my line.

[quote name='Olof Hedman' timestamp='1352209302' post='4998019']
Or do you mean that you need some kind of representation of the objects orientation(rotation), you can write to file, and don't care what this looks like, as long as you can recreate the orientation later?
[/quote]

What I needed or need, is the angles as degree or radians, because that info I want to write to a file, is needed by other tool, and that app reads only degrees or radians. Yes, if I only wanted to recreate the object orientation later in my tool, I would save the matrix or the axis vector or whatever. I think that i will have to stick with the Euler angles and see what to do with them. :/
Thanks for taking care,
good luck!!

Share this post


Link to post
Share on other sites
lauris71    841
You may take look into my matrix-to-euler-angles implementation:
[url="http://khayyam.kaplinski.com/2011/06/more-about-matrix-to-euler-angles.html"]http://khayyam.kapli...ler-angles.html[/url]

I also needed Euler angles for animation and thus had to code a specific solution for my needs. Basically it decomposes matrix to Euler angles obeying two constraints:[list=1]
[*]The set of angles generated was the one of two possible sets that was closest to predefined angles (rest pose)
[*]In case of gimbal lock the X rotation was not chosen arbitrarily, but using predefined value (the angle of previous rotation or rest pose rotation).
[/list]
It also allows arbitrary order of rotations (XYZ, XZY...)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this