Author Topic: Fun time with angles  (Read 1742 times)

0 Members and 1 Guest are viewing this topic.

Alright I'm having a hard enough time with ship rotation deltas I've started diving into quaternions.
Using excel spreadsheet:

Assume it starts at A1
=COS(Z) * COS(Y)=SIN(Z)*COS(X) + COS(Z)*SIN(Y)*SIN(X)=SIN(Z)*SIN(X) -COS(Z)*SIN(Y)*COS(X)
=-SIN(Z)*COS(Y)=COS(Z)*COS(X) - SIN(Z)*SIN(Y)*SIN(X)=-COS(Z)*SIN(X)+SIN(Z)*SIN(Y)*COS(X)
=SIN(Y)=COS(Y) * SIN(X)=COS(Y)*COS(X)

If I punch in the right X,Y,Z then the results will look good compared to the in-game Orientation matrix. 

Then I convert that matrix into a quaternion:
QW =SQRT(1+A1+B2+C3)/2
QX =(C2-B3)/(4*qw)
QY =(A3-C1)/(4*qw)
QZ =(B1-A2)/(4*qw)

Say i take (0,0,45)
I get :
.713.700  0
-.700.713  0
00  1

Problem is the results are W=.92541 X = 90, Y = 90 Z = 45
Why the 90's?


Or better yet.. does anyone have a good way of taking the change in a ships rotation and comparing it to the previous frame's  i.e. the delta change in pitch/bank/roll for all three axises?
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Here's a resource that looks like it should have everything you need... http://www.flipcode.com/documents/matrfaq.html

Euler to quat is #60

Oddly, I don't see anything about quat to euler angles, but it seems to have quat to rotation matrix, so maybe that's good enough?

 
Sorry aardwolf, should have deleted this thread.  Turns out I was doing this the hard way.  The values I was trying to calculate were already done  (ship.Physics.RotationalVelocity)
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
meh dont worry about it, that link has some useful information in it (namely all the stuff i didnt know about quats :D ).
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Sorry aardwolf, should have deleted this thread.  Turns out I was doing this the hard way.  The values I was trying to calculate were already done  (ship.Physics.RotationalVelocity)

Oh! I saw the post where you said that, but I thought you were saying you had found a way around some other aspect of it or something idk derp :)

@Nuke: be sure to unit test anything you take from there... IIRC I had to make some corrections to get the Mat3-->quat conversion working right, there might be other errors as well

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
there were some things i didnt know, like that conjugates are easy as **** to compute, and you cant just use an axis and a rotation as a quat (hince most of the quat functions i posted for scooby were completely wrong).
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN