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

    Polygons facing each other [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 545 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

      On 28/04/2016 at 15:23, xxxxxxxx wrote:

      I have a list with all the normals of all the polygons of an object, that I calculated with this code:

      for p in polygons:
           a,b,d = points[p.a],points[p.b],points[p.d]
           normals.append((b - a).Cross(d - a).GetNormalized())

      With this information available, how can I check if two faces are:

      - roughly facing each other
      - roughly facing in the same direction
      - roughly facing opposite directions

      ?

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

        On 29/04/2016 at 11:00, xxxxxxxx wrote:

        These are the possible cases. How can I detect them all? Anyone?

        http://s32.postimg.org/q1libis7p/Normals.jpg

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

          On 29/04/2016 at 12:43, xxxxxxxx wrote:

          You can compute the angle between the normal vectors of the polygons using the dot product.

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

            On 29/04/2016 at 12:50, xxxxxxxx wrote:

            I know that, Niklas.
            But in my image, for example, the angles between the normals in the second and third case is the same: around 180°
            How can I differentiate them?

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

              On 29/04/2016 at 15:45, xxxxxxxx wrote:

              I guess I found a way.
              If the angle between the normal is less than 90°, they are pointing in the same general direction.
              If the angle is between 90° and 180°, I check if a point of one of the polygons(the center of a polygon) is in front of the other polygon or not.
              If it is, the polygons are facing each other.
              if not, they are facing in opposite directions.
              Am I right?

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

                On 30/04/2016 at 12:39, xxxxxxxx wrote:

                Just to let everyone know that it worked

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