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 for polygon

    Cinema 4D SDK
    python
    2
    3
    726
    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.
    • KantroninK
      Kantronin
      last edited by

      Hi,
      I want to do a rotation for a polynone.
      I know the coordinates of the points of the polygon, in the global coordinate system.
      For this rotation, I know the axis of rotation, defined by a vector V, and the angle of rotation A with respect to this axis.

      I manage to do this type of rotation, with matrices and with a change of Cartesian coordinate system, but I know that there is a much simpler method with C4D python functions

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @Kantronin
        last edited by

        Hello @kantronin,

        Thank you for reaching out to us. I am not quite sure how your last sentence is meant,

        I manage to do this type of rotation, with matrices and with a change of Cartesian coordinate system, but I know that there is a much simpler method with C4D python functions

        but you can define a rotation matrix from an axis of rotation v and an angle w with the function c4d.utils.RotAxisToMatrix(v, w). I.e., to transform vertices of an object, you would do something like this:

        axis: c4d.Vector = c4d.Vector(1, 2, 3)
        theta: float = c4d.utils.DegToRad(45)
        transform: c4d.Matrix = c4d.utils.RotAxisToMatrix(axis, theta)
        
        transformedPoints: list[c4d.Vector] = [transform * p for p in somePointObject.GetAllPoints()]
        

        This transformation would however here happen in local object space, i.e., the space vertices/points are being expressed in. If you want to do the rotation in a space relative to the polygon, you will have to construct a frame for that polygon first, then convert the points out of local object space into your custom polygon space, carry out your rotation, and then convert the points back. I am just mentioning this because you talk about '[..] do[ing] a rotation for a polyon' which somewhat implies that you want to rotate around the origin of the polygon and some frame implied by the polygon.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        KantroninK 1 Reply Last reply Reply Quote 0
        • KantroninK
          Kantronin @ferdinand
          last edited by

          @ferdinand

          Thanks, it works well

          My first method was complex:

          • creation of a new orthogonal spatial system, with one of its axes is identical to the axis of rotation
          • compute the coordinates of the points of the object in this new spatial system, then rotate the object
          • calculation of the new coordinates in the initial orthogonal spatial system.
          1 Reply Last reply Reply Quote 0
          • First post
            Last post