Author Topic: RotationMatrix  (Read 4396 times)

Offline guiloic

  • byte
  • *
  • Posts: 24
    • View Profile
RotationMatrix
« on: June 05, 2006, 12:39:44 pm »
How can I calculate the angle from a RotationMatrix ?

thx
ww.devcat.org

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
RotationMatrix
« Reply #1 on: June 06, 2006, 04:44:29 pm »
This should (may...:wink: ) work:

Code: [Select]
 
public SimpleVector deriveAngles(Matrix mat) {
    SimpleVector s=new SimpleVector();
    float[] m=mat.getDump();
    s.x=(float) Math.atan(m[9]/m[10]);
    s.y=(float) Math.asin(-m[2]);
    s.z=(float) Math.atan(m[4]/m[0]);
    return s;
}


But keep in mind that rotations depend on each other, i.e. after doing a rotateX(0.1f); rotateY(0.1f); rotateZ(0.2f), the result won't be (0.1,0.1,0.2). Plus there are multiple posibilities to get the same result out of different rotations, i.e. the resulting angles show no "history" of former rotations.

Hope this helps.