Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    MatrixToRotAxis is nummerically instable

    Scheduled Pinned Locked Moved Bugs
    1 Posts 0 Posters 544 Views
    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 Offline
      Helper
      last edited by

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

      On 09/09/2005 at 08:26, xxxxxxxx wrote:

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

      ---------
      Hello

      The problem in MatrixToRotAxis is this code

      // Achse berechnen
           v->x= m.v2.z-m.v3.y;
           v->y= m.v3.x-m.v1.z;
           v->z= m.v1.y-m.v2.x;
           *v = !(*v);

      if the matrix is near identity then v will be really small.. the normalization however will bring it to length 1. This results in an almost random unit vector. Which is now our rotation axis.. 😞

      My workaround is:

      Quaternion q;
           q.SetMatrix(LM(m));
           if(Len(q.v)<1.0e-6) {
                v = Vector(1,0,0);
                w = 0;
           }
           else {
                v = SV(!(q.v));
                w = 2.0*acos(q.w);
           }

      Not that you would call this efficient. But it seems to work.

      best regards
      Michael

      1 Reply Last reply Reply Quote 0
      • First post
        Last post