PDA

View Full Version : AngleAxis and Quaternion.


eek
07-09-2006, 06:43 PM
Is AngleAxis essentially the same as Quaternion. As defining either uses both a vector (the unit point) and an angle (unit sphere)?

e.g.

n = normalize(a-b)

quat (n.x n.y n.z 90) == angleaxis (90 n.x n.y n.z)

Ive also been reading that AngleAxis from matrixs below -180, wont work. Eg. [1,0,0] [0,-1,0],[0,0,-1]

Kenzor
07-15-2006, 09:50 AM
As i understand it ..
Angle axis defines a rotation transfrom by an Axis and a rotation about that axis (circle)

Quaterions are similar but us complex numbers...

to get from Angle Axis to Quaterion do

AngleAxis ( [ax,ay,az] angle )

qx = ax * sin(angle/2)
qy = ay * sin(angle/2)
qz = az * sin(angle/2)
qw = cos(angle/2)

quat (qx,qy,qz,qw)

LoneRobot
07-19-2006, 09:15 AM
Ah now there's the answer to a question that's been bugging me too. I couldn't figure out how to use quat in the particular context i was looking for, but angle axis worked fine and would take the variable from a slider. I see why now. thanks.

eek
07-19-2006, 02:41 PM
Quaternions and Angleaxis are essentially the same.

With quats yes you deal with not only complex but also imaginary numbers, as in the formula
i^2=j^2=k^2=ijk= -1. They are very complex as the you have a vector inside a 4d hypersphere, its vector across this sphere defines its angle and its rotation about this vector defines its twist as in: n= (v,r) (its not even a vector)

But the issues i have is that the rotation round the vector defined by the first three values i.e the normalise v. Also affects v, its all solved as one which makes it very complex.

With angleaxis its the same, you cant feed it a normalised vector and expect a angle about that axis to be unique, the vector and the angle work as one. As the algorithm is solved as one, affecting one part affects the whole part.

Essentially i just wanted to have an object look at another object, and rotate round it about the vector it looks at. I know i can do this with a matrix, but its the +360 thing i like.

The issue also comes form the transform relativity problem, ie relative to there parent, the coordinate space they work it. I think i may have to read up on matrix projection methods.

LoneRobot
07-19-2006, 04:10 PM
so is it possible to convert from a point3 rotation to a quaternion? i read in the MXS help there is <matrix3> as quat-- extracts the rotation component as a quat


is this right? can you get the output from a eulerXYZ and convert or are there implications to do with all that nasty gimbal lock mularkey? :shrug:

PEN
07-19-2006, 05:36 PM
so is it possible to convert from a point3 rotation to a quaternion? i read in the MXS help there is

is this right? can you get the output from a eulerXYZ and convert or are there implications to do with all that nasty gimbal lock mularkey? :shrug:



Yes you can convert from one to the other. There are always issues that come up because eulers have their problems, like gimble lock. Eulers are really a very inaccurate way to calculate a rotation in 3D space, hence the need for a quat value. I always try to avoid doing any euler math with rotations and work out the quat or the matrix values and then convert those to Euler if I need to. I will avoid converting the other way because you take any issues you have with the euler and just pass it to the quat.

I think for the most part I work with Matrix values then get the quat value from that. I don't fully understand quats either to be able to get the results that I need and a matrix is really simple. It is easy to work out a lookAt controller type setup that Eek is wanting to do by just calculating the vectors that are needed then get the rotation part of matrix and apply it to the object.

eek
07-19-2006, 07:32 PM
I think for the most part I work with Matrix values then get the quat value from that. I don't fully understand quats either to be able to get the results that I need and a matrix is really simple. It is easy to work out a lookAt controller type setup that Eek is wanting to do by just calculating the vectors that are needed then get the rotation part of matrix and apply it to the object.


I think this is the way to go. Matrix math is a little easier than quaternion imaginaries, even matrix projections are easier than quat math. Also matrix are defined by there row, x y z w, which makes it a lot easy. Quat that whole lot is evaluated, but the difference being you dealing just with rotations.

I think I understand quaternions essentially, the vector and the engle. What makes them incredibly more complex is defining the origin of the angle defined by the vector i.e 0 value, as you have to take into account the orientation of the hypersphere itself this adds another chunk of complexity, which basically makes my head explode! Plus the fact that the x y z on the hypersphere are the cosine(theta/2) it gets really really complicated.

PEN
07-20-2006, 11:48 AM
I really should at some time try to get my head around it better, not having a back ground in Math is hurting my ability to just read some math help and pick it all up though. I use Quats for some things but like you say they do start to make my head hurt at times. I wonder how how much slower it is to calculate a matrix and then convert that to a quat is then just calcuating the quat. Has any one ever done any tests?

eek
07-20-2006, 10:14 PM
I really should at some time try to get my head around it better, not having a back ground in Math is hurting my ability to just read some math help and pick it all up though. I use Quats for some things but like you say they do start to make my head hurt at times. I wonder how how much slower it is to calculate a matrix and then convert that to a quat is then just calcuating the quat. Has any one ever done any tests?

I wonder? I think the matrix to quat does some pretty crazy things, i wonder too how quick a straight calculation of quat is. I got a little into before screaming!

CGTalk Moderation
07-20-2006, 10:14 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.