0

I am rendering model using quaternions. When model is moving, I need to find angle between two quaternions which I am getting through resultant of difference quaternions and using this formula

 float angle = acosf(res.w) * 2.0f * 57.2957795f; 

Here I can get angle easily. But I need to find whether this angle is clockwise or anticlockwise.

Is any glm api for that or how can identify direction of movement. Here my modal is moving perfectly in both direction (CW & ACW), but it gives positive angle only. Or am I doing something wrong in angle calculation?

Nicol Bolas
  • 378,677
  • 53
  • 635
  • 829
Aditya Kumar
  • 5
  • 1
  • 6
  • 3
    What is a quat? Is that a nickname for quaternion? The right hand rule should tell you without any problem. Both the CW or anti-CW answers are "correct" - which one would you choose for your situation? Math can't help with that. – duffymo Nov 01 '17 at 12:41
  • The arcus cosinus can only compute the angle up to some sign. The arcus sinus can determine the sign, but will fail if the magnitude of the angle exceeds 90°. Often you can combine them and use atan2 instead. See https://stackoverflow.com/q/14066933/1468366 for a generic question to this effect. In my answer there I note how having a sign in a 3d rotation is often a meaningless concept. – MvG Nov 01 '17 at 22:52
  • @duffymo yes, quat is quaternion. How will right hand rule will tell CW and ACW? – Aditya Kumar Nov 02 '17 at 05:01
  • @MvG Thanks, I am using quat to determining angle. And I think it is right. Here my problem is to given two or more quaternions how will i know that rotation is in CW or ACW. – Aditya Kumar Nov 02 '17 at 05:09

0 Answers0