Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Rotation, HPB & Quaternions

    SDK Help
    0
    2
    272
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 25/04/2007 at 06:00, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   9.603 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      There seems to be a problem with the Quaternion::SetMatrix() function.

      I'm writing a directX exporter and until now I used matrices to animate a model. Due to the limitations (gimbal lock) I switched to Quaternions.

      Now here's the problem:
      a cube with a rotation of 360° along the Y axis.
      Exporting the animation with a 4x4 Matrix -> everything is fine
      Exporting the animation with Quaternions -> everything is fine until the rotation is > 180° (pi).
      HPB Values higher than pi get a wrong sign in the quaternion which causes rotation to spin back very fast

      Has anyone experienced something similar?
      And are there solutions?

      Any help is greatly appreciated

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 27/04/2007 at 04:12, xxxxxxxx wrote:

        After 2 days of comparing values and try and error I found the problem.

        To build my quaternion I used

        rotquat.SetMatrix(LHPBToMatrix(LV(dtRot)));

        But (of course) this doesnt work, because the "regular" Matrix brings the gimbal problem back.

        The correct way to do this is like this:

          
                  Quaternion rotquat, rotquatX, rotquatY, rotquatZ;  
                  //rotquat.SetMatrix(LHPBToMatrix(LV(dtRot)));  
                  rotquatX.SetAxis(LVector(1, 0, 0), dtRot.y);  
                  rotquatY.SetAxis(LVector(0, 1, 0), dtRot.x);  
                  rotquatZ.SetAxis(LVector(0, 0, 1), dtRot.z);  
                  //ZYX  
                  rotquat = QMul(rotquatZ, QMul(rotquatX, rotquatY));  
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post