Author Topic: Calculating rotation angle  (Read 2782 times)

Offline gamerfan

  • int
  • **
  • Posts: 97
    • View Profile
Calculating rotation angle
« on: September 08, 2011, 09:29:27 am »
Hi,
I am rotating a box and want to calculate the rotation angle for every point that it rotates in 3d world.The box rotates on Y-axis.How can I do that? Thanks in advance

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Calculating rotation angle
« Reply #1 on: September 08, 2011, 09:33:30 am »
The angle between...what? I'm not sure what you mean with "rotation angle for every point"?

Offline gamerfan

  • int
  • **
  • Posts: 97
    • View Profile
Re: Calculating rotation angle
« Reply #2 on: September 08, 2011, 09:42:01 am »
The box rotates on y-axis.so every time when I press a key it rotates on y-axis. At that point can we know how much angle swept by this 'rotation'.Is it clear now?  :)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Calculating rotation angle
« Reply #3 on: September 08, 2011, 09:51:33 am »
You can use this method: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/SimpleVector.html#calcAngle(com.threed.jpct.SimpleVector) to calculate the angle between (0,0,1) and box.getZAxis(). However, try to avoid working with angles if possible. Matrices are far superior.

Offline gamerfan

  • int
  • **
  • Posts: 97
    • View Profile
Re: Calculating rotation angle
« Reply #4 on: September 08, 2011, 10:55:12 am »
Thanks it worked.I used box.getTransformedCenter().calcAngle(box.getXAxis()) this will return angle swept by the rotation