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

    HPB rotation to rotation around axis

    General Discussion
    0
    3
    1.2k
    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 05/11/2003 at 15:51, xxxxxxxx wrote:

      Hi,

      how can I convert rotation of object (obtained using GetRot(), i.e. HPB vector) to rotations around x,y,z axis? I've been trying to do it this way:

      Matrix mrz = Matrix::rotateZ(rz);
              Matrix mry = Matrix::rotateY(ry);
              Matrix mrx = Matrix::rotateX(rx);
              return mrz * mry * mrx;

      where the matrices are 4x4 OpenGL matrices and rotate{X,Y,Z} are rotations around axis X, Y and Z respectively and the argument is in radians. It's same as this sequence of OpenGL calls:

      glRotatef(rad2deg(rz),0,0,1);
              glRotatef(rad2deg(ry),0,1,0);
              glRotatef(rad2deg(rx),1,0,0);

      Is this correct or does Cinema4D use different semantics? I can't make it work...

      Thanks!

      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 21/11/2003 at 07:47, xxxxxxxx wrote:

        Why use XYZ rotations? GL directly allows to set a Matrix. (If you still need the rotation thingy, take a look at GraphicsGems 4, they have source code for calculating rotations from a matrix).
        Matrix mg=op->GetMg();
        Real c[16];
        c[0] = mg.v1.x;
        c[1] = mg.v1.y;
        c[2] = mg.v1.z;
        c[3] = 0;
        c[4] = mg.v2.x;
        c[5] = mg.v2.y;
        c[6] = mg.v2.z;
        c[7] = 0;
        c[8] = mg.v3.x;
        c[9] = mg.v3.y;
        c[10] = mg.v3.z;
        c[11] = 0;
        c[12] = mg.off.x;
        c[13] = mg.off.y;
        c[14] = mg.off.z;
        c[15] = 1;
        glLoadMatrixf(c);

        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 22/11/2003 at 04:35, xxxxxxxx wrote:

          Quote: _Why use XYZ rotations? GL directly allows to set a Matrix.
          >
          > * * *
          _


          Why, because I need them, I didn't say I'm using OpenGL. Besides, the matrix would still not be usable in OpenGL because c4d uses left-handed coordinate system and OpenGL uses right handed-one.

          I figured it out in the meantime, so in case anybody ever needs something similar, it's like this:
          C4d uses left-handed system. HPB rotation translates to rotation about axes in this way: H is rotation around (0,-1,0) axis (y-axis, the angle is negated), P around (-1,0,0) and B around (0,0-1). Accounting for OpenGL's right-handed system, the rotations will become
          rx = p
          ry = h
          rz = -b
          When applying the rotation, the order is rotY(ry)*rotX(rx)*rotZ(rz)

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