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

    Transform coordinates of a polygon's points

    Cinema 4D SDK
    4
    5
    1.3k
    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,

      C4D has a complex coordinate system.

      • world coordinates
      • local coordinates
      • object coordinates (we can see them in the outliner, for selected object)

      For the problem I am asking, I don't wish to have a general theory answer, concerning the coordinates system, but to obtain precise answers.

      Here is my problem:

      For a polygon, we can get easily the array of points and then display the position of this points as follows:

      tabPoint = polygon.GetAllPoints()
      for point in tabPoint:
      	print point
      

      But I would like to knowhow to display the position of points of this polygon in the World coordinates ?
      Then if I change the World coordinates of some points, how to convert this coordinates for modify the array of points for this polygon ?

      I indicate below in what order are these two questions:

      • Step 1: access the array of points for a polygon and therefore access the coordinates (very easy)
      • Step 2: Conversion of these coordinates to world coordinates (first question)
      • Step 3: change the position of some points of this polygon in the world coordinates (very easy)
      • Step 4: Conversion of these world coordinates to the format of the array of points for this polygon (second question)
      • Step 5: Modification of this polygon with the new array of point (very easy)

      You may want to know why I am asking these questions, here is the reason.
      I have two polygons that represent cliffs, but they do not coincide very well.
      I have to bring closer the dots of theses cliffs to obtain a perfect join.
      I'm doing this work to make a canyon that I started in opensim (see link below)
      my cliffs before the junction of points
      My points alignment algorithm works well, but I'm stumbling on that damned C4D coordinate system !

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by

        Get the object's (polygon, in this case) world matrix through GetMg(). Multiply the point's coordinates with that matrix to transform their local coordinates into world coordinates. Use the inverted matrix to convert the world coordinates back.

        (It is really hard to answer that without general theory.)

        1 Reply Last reply Reply Quote 1
        • KantroninK
          Kantronin
          last edited by

          Indeed, it is necessary to use two matrices
          For an object named polygonName, we will have:

          Matrix = polygonName.GetMg ()
          inverseMatrix = ~ Matrix
          

          Matrix converts local coordinates to global coordinates.
          After finishing working in global coordinates, we return to local coordinates with inverseMatrix
          We can thus modify the polygon with the new local coordinates.

          These two matrices allow to work with the points, which is very convenient.

          This subject is very well explained here:
          Link

          1 Reply Last reply Reply Quote 0
          • S
            SmetK
            last edited by

            @Cairyn @Kantronin Hey, everybody. Could you throw a more detailed implementation code?

            i_mazlovI 1 Reply Last reply Reply Quote 0
            • i_mazlovI
              i_mazlov @SmetK
              last edited by

              Hi @SmetK,

              Please note that we have a great Matrix Manual with code samples. You can also check our github repository for the geometry examples, e.g. the Polygon Object example.

              For your further questions I kindly encourage you to create new thread and shape your posting according to how it's described in our Support Procedures: Asking Question.

              Cheers,
              Ilia

              MAXON SDK Specialist
              developers.maxon.net

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