Jump to content

  • Log In with Google      Sign In   
  • Create Account

Quaternion-Rotation to Degree (Edge-jump)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 gnomgrol   Members   -  Reputation: 627

Like
0Likes
Like

Posted 28 July 2014 - 12:28 PM

Well met!

 

This may seem like a rather simple thing, but I can't seem to figure it out or find an answer.

 

I'm trying to write an exporter for 3ds MAX, but it stores its rotations in quaternions while I need angles.

It does provide you with a function to convert them, which gives you bad angles at the edges.

 

A simple rotation around the Y axis jumps like this:

...
(quat -0.0222105 -0.706758 -0.0222105 0.706758)
(eulerAngles 90.0001 86.4 90.0001)

(quat 2.30405e-007 -0.707107 2.30405e-007 0.707107)
(eulerAngles 0 90 0)

(quat 0.0230636 -0.706731 0.0230636 0.706731)
(eulerAngles -90 86.2617 -90)
...

After some research I got told that that is the expected behavior. I tried to write my own conversion function and catch the bad angles, but failed. What exactly should I do to get the degrees?

 

I hope you can help me with this!

Thank you in advance and have a nice day!


Edited by gnomgrol, 28 July 2014 - 12:29 PM.


Sponsor:

#2 slicer4ever   Crossbones+   -  Reputation: 3989

Like
0Likes
Like

Posted 28 July 2014 - 03:44 PM

What exactly should I do to get the degrees?


don't use degrees, and go learn how complex numbers work, then quaternions should make much more sense. and don't let the name scare you, the concepts behind complex numbers is actually very simple if you take the time to understand them.

Edited by slicer4ever, 28 July 2014 - 03:47 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#3 ferrous   Members   -  Reputation: 2146

Like
0Likes
Like

Posted 28 July 2014 - 03:46 PM

You only really need a fairly basic understanding of what a Quaternion is to be able to use them effectively, and for animations, it's totally worthwhile to gain that understanding.



#4 gnomgrol   Members   -  Reputation: 627

Like
0Likes
Like

Posted 28 July 2014 - 04:33 PM

You only really need a fairly basic understanding of what a Quaternion is to be able to use them effectively, and for animations, it's totally worthwhile to gain that understanding.

 

You only really need a fairly basic understanding of what a Quaternion is to be able to use them effectively, and for animations, it's totally worthwhile to gain that understanding.

 

I had my animations implemented using Quaternions at first. 

I am currently rewriting my whole animation code based on a model suggested by L. Spiro, and so far it works out awesome. The last thing I need to get right are the rotations.

Like she mentioned in her post, Quaternions are really slow compared to matrices. And the track based animation system requires me to know every single part of the world matrix in order to gain speed.

(http://www.gamedev.net/topic/659147-optimising-bone-based-animation/#entry5169156)


Edited by gnomgrol, 28 July 2014 - 04:37 PM.


#5 slicer4ever   Crossbones+   -  Reputation: 3989

Like
0Likes
Like

Posted 28 July 2014 - 04:50 PM

You only really need a fairly basic understanding of what a Quaternion is to be able to use them effectively, and for animations, it's totally worthwhile to gain that understanding.

 

You only really need a fairly basic understanding of what a Quaternion is to be able to use them effectively, and for animations, it's totally worthwhile to gain that understanding.

 
I had my animations implemented using Quaternions at first. 
I am currently rewriting my whole animation code based on a model suggested by L. Spiro, and so far it works out awesome. The last thing I need to get right are the rotations.
Like she mentioned in her post, Quaternions are really slow compared to matrices. And the track based animation system requires me to know every single part of the world matrix in order to gain speed.
(http://www.gamedev.net/topic/659147-optimising-bone-based-animation/#entry5169156)


so why are you pulling euler angles, instead of rotation matrix's out of the exporter? i'd say keep quaternions as your animation format, and simply convert it the rotation matrix upon loading the animation.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#6 gnomgrol   Members   -  Reputation: 627

Like
0Likes
Like

Posted 28 July 2014 - 05:21 PM

Because I need the single rotations for each axis in order for the track-based animation-system to work. (But there might be a way around that)

But if I'd convert it into a rotation-matrix, I'd still get the problem at the edges,  wouldn't I?


Edited by gnomgrol, 28 July 2014 - 05:21 PM.


#7 tanzanite7   Members   -  Reputation: 1379

Like
0Likes
Like

Posted 29 July 2014 - 02:23 AM

But if I'd convert it into a rotation-matrix, I'd still get the problem at the edges,  wouldn't I?

Why would you get "problems" at the "egdes" (what edges?) with rotation matrix?

Sounds like you really should re-investigate:
* what is a rotation matrix (how it works / what it represents mathematically)
* what is a quaternion (--||--)
* what is gimbal lock in regards of euler angles ( edit: http://en.wikipedia.org/wiki/Gimbal_lock )


Edited by tanzanite7, 29 July 2014 - 02:27 AM.


#8 gnomgrol   Members   -  Reputation: 627

Like
0Likes
Like

Posted 29 July 2014 - 09:53 AM

 

But if I'd convert it into a rotation-matrix, I'd still get the problem at the edges,  wouldn't I?

Why would you get "problems" at the "egdes" (what edges?) with rotation matrix?

Sounds like you really should re-investigate:
* what is a rotation matrix (how it works / what it represents mathematically)
* what is a quaternion (--||--)
* what is gimbal lock in regards of euler angles ( edit: http://en.wikipedia.org/wiki/Gimbal_lock )

 

 

I stated what the problem is in my first post.

I understand complex numbers and quaternions as well as where the problem is coming from (Which is, as I stated, the singularity in the conversion function).

I don't really care about the one degree beeing lost due to the gimbal lock.

 

 


But if I'd convert it into a rotation-matrix, I'd still get the problem at the edges,  wouldn't I?

This was supposed to mean that the conversion problem that occurs when converting to degrees also would occur when converting to a matrix.


Edited by gnomgrol, 29 July 2014 - 09:57 AM.


#9 tanzanite7   Members   -  Reputation: 1379

Like
1Likes
Like

Posted 31 July 2014 - 04:33 PM

But if I'd convert it into a rotation-matrix, I'd still get the problem at the edges,  wouldn't I?

This was supposed to mean that the conversion problem that occurs when converting to degrees also would occur when converting to a matrix.

Uh?

There are no conversion problems when converting quaternion to matrix (*) - did you mean from matrix to Euler angles? Then yes, whatever is the perceived problem with quaternion->euler (I am not sure what the problem is - are the values wrong? Why do you care that the values jump around a bit?) would probably crop up again.

Euler angles are usually terrible to work with (expensive, capricious and shall i say - bloody useless. IMMHO, aka YMMV), i would repeat the advice to use a quaternion and/or matrix where appropriate instead.

*) Quaternion transforms fairly easily into a neat equivalent rotation-only matrix (Orthonormal basis. So, just a bunch of unit length orthogonal axis vectors).

Perhaps useful for reference:
http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/index.htm
http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm
http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm

#10 Kaptein   Prime Members   -  Reputation: 2180

Like
0Likes
Like

Posted 31 July 2014 - 06:04 PM

If you really know quaternions, as you say, although I'm not convinced, then this may help you:

http://wscg.zcu.cz/wscg2012/short/a29-full.pdf

 

Dual quaternions are excellent for this, especially if you're rolling your own.

Also, don't use matrices (where you don't have to) until the very last moment just before you shove it into GL

 

And... where does degrees come into this? Is it something that comes from 3ds max?


Edited by Kaptein, 31 July 2014 - 06:06 PM.


#11 gnomgrol   Members   -  Reputation: 627

Like
1Likes
Like

Posted 02 August 2014 - 12:26 PM

Thanks to all of you. I switched to using Matrices and it works out fine now :)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS