sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Which face is closest?

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 3 Posters 228 Views 3 Watching
    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.
    • voljankoV Offline
      voljanko
      last edited by

      3 faces connected on 1 edge.
      Want to know which face is closest to face1 (face2 or face3),if I look from the back face side.
      I know face2 is closest,but want Ruby to decide πŸ˜„
      I have experimented with normal.angle_between but no success.
      Any suggestions?


      3faces.JPG

      SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

      1 Reply Last reply Reply Quote 0
      • K Offline
        kyyu
        last edited by

        How about comparing distance to face center points (face.bounds.center)?

        1 Reply Last reply Reply Quote 0
        • voljankoV Offline
          voljanko
          last edited by

          @kyyu said:

          How about comparing distance to face center points (face.bounds.center)?

          Hmm,seems too dependent of the face size.Should be size independent and also face shape independent.

          SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            'Closest' is an inappropriate term [to be picky it should be 'closer' as there are only two more to choose from].
            If we only have two faces we just know the second face is always 'closest' to the first face.
            When we have three [OR more faces] they all have normal vectors.
            We take the normal of the initial face and compare it to the normals of the others.
            We do this using v0.angle_between(v1), v0.angle_between(v2) etc.
            There are several possible outcomes...
            The angles are all the same - therefore no face is 'closest' OR they all are!
            Some faces [assuming that there are more than two to choose from] share the same minimum subtended angle - so now we have some 'closest faces'.
            There is only one face that subtends an angle which is less than any of the others, and therefore we now have the 'closest' face.
            You cannot have arbitrary rules about the front/back of the face.
            You can test for the initial face actual normal and normal.reverse - you will/might get two results... BUT how will you choose which one to use ??

            TIG

            1 Reply Last reply Reply Quote 0
            • voljankoV Offline
              voljanko
              last edited by

              @tig said:

              You cannot have arbitrary rules about the front/back of the face.

              This is the biggest sub-problem in this problem,I think.
              There is a face side entity missing.

              SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

              1 Reply Last reply Reply Quote 0
              • TIGT Offline
                TIG Moderator
                last edited by

                Please explain what you mean exactly ?
                I don't understand you...
                If you want to know the orientation of a face relative to its edge, then use this http://code.google.com/apis/sketchup/docs/ourdoc/edge.html#reversed_in?
                You can then compare the three faces sharing a common edge and if one is 'backwards' used face.reverse! OR use face.normal.reverse in the testing ???

                TIG

                1 Reply Last reply Reply Quote 0
                • voljankoV Offline
                  voljanko
                  last edited by

                  @tig said:

                  If you want to know the orientation of a face relative to its edge, then use this http://code.google.com/apis/sketchup/docs/ourdoc/edge.html#reversed_in?
                  You can then compare the three faces sharing a common edge and if one is 'backwards' used face.reverse! OR use face.normal.reverse in the testing ???

                  This could be exactly what I need,have to test first.
                  Thanks.

                  SuSolid.com - solid check - solid repair- solid intersection check - weight plugin

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Buy SketchPlus
                  Buy SUbD
                  Buy WrapR
                  Buy eBook
                  Buy Modelur
                  Buy Vertex Tools
                  Buy SketchCuisine
                  Buy FormFonts

                  Advertisement