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

    Transfer Scale from one Matrix to another

    SDK Help
    0
    5
    445
    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

      On 06/12/2013 at 02:03, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R13-R14 
      Platform:   Windows  ;   
      Language(s) :      XPRESSO  ;

      ---------
      I am not sure how to do this.
      For the position, is is easy:

      Matrix matrix_A;
      Matrix matrix_B;
      matrix_B.off = matrix_A.off;
      

      What is the corresponding way for the scaling?

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

        On 06/12/2013 at 04:39, xxxxxxxx wrote:

        In order to get the scales (vector) out of a matrix, you need to get the length of each axis basis:

        Vector scale = Vector(Len(matrix_A.v1), Len(matrix_A.v2), Len(matrix_A.v3);  
        matrix_B.v1 = !matrix_B.v1 * scale.x;  
        matrix_B.v2 = !matrix_B.v2 * scale.y;  
        matrix_B.v3 = !matrix_B.v3 * scale.z;  
        

        This information is in the SDK documentation.

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

          On 06/12/2013 at 05:11, xxxxxxxx wrote:

          Ok, thanks, tat is indeed a lot, just to keep the scaling.
          I often do some calculations on Quaternions, and the unwanted side effects is that scaling is influenced too, even if it is the rotation only, that I am interested in.

          Quaternion q_A;
          q_A.SetMatrix(inputMatrix);
          Quaternion q_B = QMul(q_A, 1.5);
          Matrix resultMatrix = q_B.GetMatrix();
          

          I get the resulting rotation I am after,  but I get the scale multiplied by 1.5 too.
          So I have to write the code you submitted, OK. No simpler way..

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

            On 06/12/2013 at 06:14, xxxxxxxx wrote:

            You could simply get the normalized matrix.  That is, it will only contain the rotations and turn any scaling into unity (1s).

            Matrix resultMatrix = q_b.GetMatrix();  
            resultMatrix.Normalize();
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 06/12/2013 at 06:38, xxxxxxxx wrote:

              I will have a look at Normalize(), maybe it will do what I want. But in case the original scale is _<__>_ 1, I will need to use the first code you provided.

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