sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Angle between two edges in a face?

    Scheduled Pinned Locked Moved Developers' Forum
    11 Posts 3 Posters 690 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.
    • cottyC Offline
      cotty
      last edited by

      Are you able to provide a little image which shows the variables vector1, vector2, normal?
      Cotty

      my SketchUp gallery

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @cotty said:

        Are you able to provide a little image which shows the variables vector1, vector2, normal?
        Cotty

        I added more to the description in the original post.

        full_angle_between.png

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

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          If it is of any importance, "vector1" and "vector2" was just picked at random in the illustration. The red "vector1" might be "vector2" for all I know.

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

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            The order of how I received the vectors seemed to make the difference.

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

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

              ### this code lists each vertex with its angle, for a selected face
              def vangles()
                model=Sketchup.active_model
                ss=model.selection
                face=ss[0]
                edges=face.edges
                edges << edges[0]
                pairs=[]
                edges[0..-2].each_with_index{|e,i|
                  pairs << [e,edges[i+1]]
                }
                norm=face.normal
                angles=[];ctr=0
                pairs.each{|pr|
                  e0=pr[0]
                  e1=pr[1]
                  vert=e0.start
                  verts=e0.vertices+e1.vertices
                  b=Hash.new(0)
                  verts.each{|v|b[v]+=1}
                  b.each{|k,v|vert=k if v > 1}
                  everts=verts-[vert]
                  vec0=vert.position.vector_to(everts[0])
                  vec1=vert.position.vector_to(everts[1])
                  angle=(vec0.angle_between(vec1))
                  angle=360.degrees-angle if norm==(vec0*vec1).normalize!
                  angles << [ctr, angle.radians]
                  ctr+=1
                }
                puts angles
              end
              ###
              

              TIG

              1 Reply Last reply Reply Quote 0
              • cottyC Offline
                cotty
                last edited by

                Is it possible to calculate two angles, one for +direction and one for -direction and chose the little one? I don't know about ruby, sorry...
                Cotty

                my SketchUp gallery

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  I've solved the problem. Code is posted in this thread: http://forums.sketchucation.com/viewtopic.php?f=180&t=39625

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

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

                    @thomthom said:

                    I've solved the problem. Code is posted in this thread: http://forums.sketchucation.com/viewtopic.php?f=180&t=39625

                    Which presumably has a similar affect as my code ?

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      @tig said:

                      @thomthom said:

                      I've solved the problem. Code is posted in this thread: http://forums.sketchucation.com/viewtopic.php?f=180&t=39625

                      Which presumably has a similar affect as my code ?

                      Angles seem to be correct, until you add a hole on the face. Then your pairs won't be correct as one pair might contain edges from two different loops.

                      And my starting position is with a vertex given - and from there I need to work out it's normal. To process the whole face would lead to duplicate processing.

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

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

                        My code was a quick example to show that you could get the correct angles.
                        Of course edges=face.edges can easily be replaced with edges=face.outer_loop.edges or we iterate through the loops to get their edges in turn...
                        BUT if its for only one vertex it's then easy enough to find the two edges belonging to that vertex [and that face] and run similar code on them to get the angle between them, using the face normal and vectors cross comparison to trap for concave corner angles >180 degrees... remembering to trap for ==180.degrees, as well as < and >...

                        TIG

                        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