• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

[Code] Skew Transformation from axes

Scheduled Pinned Locked Moved Developers' Forum
21 Posts 8 Posters 3.7k Views 8 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.
  • F Offline
    fredo6
    last edited by 3 Jun 2016, 15:32

    Dot product is 0 if the vectors are perpendicular.
    It is 1 if they have the same direction (assuming they are normalized) and -1 for opposite direction.

    Fredo

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 4 Jun 2016, 09:35

      @fredo6 said:

      "assuming they are normalized"

      Does normalizing first remove any variance that could throw off the comparison (with -1, 0 or 1) afterward ?

      Or would it be safer to use:
      vec1.perpendicular?(vec2)
      vec1.parallel?(vec2) && vec1.samedirection?(vec2)
      vec1.parallel?(vec2) && ! vec1.samedirection?(vec2)

      I also wonder about ThomThom's magic comparison.

      Is it the same on 64-bit SketchUp ?

      I mean why 10 decimal places ? Is it SketchUp's internal tolerance ?

      Ie, (0.001 x 0.001 x 0.001) ... which is 9 decimal places.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdmitch
        last edited by 12 Nov 2016, 17:00

        If you have a component instance that has been skewed, how do you determine which axis is skewed?

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 17 Nov 2016, 16:29

          @fredo6 said:

          ...and there is the magic formula by thomthom to check if two faces are coplanar (actually have parallel planes)

          face1.normal % face2.normal > 0.9999999991

          Fredo

          hm... this must be something from and old version of CleanUp? It was never reliable. What I do now is take all the vertices of the faces and generate a best-fit plane - then I check if each of the vertices is on the plane.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • F Offline
            fredo6
            last edited by 17 Nov 2016, 16:49

            Well, I think I found it it an old post!. And it seems to work fine for the purpose.

            Indeed there are alternate methods, the problem being to detect the false positive, that is faces that would be co-planar by the formula, but would not in the model drawn by Sketchup.

            Fredo

            1 Reply Last reply Reply Quote 0
            • D Offline
              Dan Rathbun
              last edited by 17 Nov 2016, 21:32

              @thomthom said:

              @fredo6 said:

              ...and there is the magic formula by thomthom to check if two faces are coplanar (actually have parallel planes)
              face1.normal % face2.normal > 0.9999999991

              hm... It was never reliable.

              I was hoping you'd answer the questions I posed (above) in this post:
              http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=65068%26amp;view=unread#p597160

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • F Offline
                fredo6
                last edited by 17 Nov 2016, 23:27

                Face.normal returns a normalized vector.

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 18 Nov 2016, 13:23

                  @fredo6 said:

                  Well, I think I found it it an old post!. And it seems to work fine for the purpose.

                  Indeed there are alternate methods, the problem being to detect the false positive, that is faces that would be co-planar by the formula, but would not in the model drawn by Sketchup.

                  Fredo

                  Checking the plane might in some cases yield false for some cases where SU is able to merge. But this is rare. Comparing normal had the opposite of yielding true in cases where SU would not be able to merge.

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 18 Nov 2016, 13:24

                    @dan rathbun said:

                    @thomthom said:

                    @fredo6 said:

                    ...and there is the magic formula by thomthom to check if two faces are coplanar (actually have parallel planes)
                    face1.normal % face2.normal > 0.9999999991

                    hm... It was never reliable.

                    I was hoping you'd answer the questions I posed (above) in this post:
                    http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=65068%26amp;view=unread#p597160

                    As Fredo mentions, face.normal already return a unit vector. The issue is that comparing vectors is too unreliable in edge cases.

                    Thomas Thomassen — SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      Dan Rathbun
                      last edited by 18 Nov 2016, 20:45

                      So what is the solution here?

                      Is it some extra text in the API docs explaining how best to test for face coplanarity ?

                      Or would it be a new API method for the Sketchup::Face class:
                      face.coplanar_with?(other_face)
                      or a module method?:
                      Geom::faces_coplanar?(face1,face2)

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        thomthom
                        last edited by 20 Nov 2016, 18:18

                        No sure where it would fit in the docs. Maybe we can add a Wiki section on the GitHub repo that host the new docs.

                        This scenario is so common though that a face.coplanar_with?(other_face) might be a nice addition.

                        Thomas Thomassen — SketchUp Monkey & Coding addict
                        List of my plugins and link to the CookieWare fund

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

                        Advertisement