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

    Problem with face.normal directions...help!

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 5 Posters 446 Views 5 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.
    • renderizaR Offline
      renderiza
      last edited by

      In the graph below I can work out if a face is normal is facing on the direction specified in the first four examples. But I don't know how to evaluate if a face normal is facing giving the directions specified in the last four graph examples. Any help will be Appreciated!

      http://s11.postimg.org/jj4tvgdki/question.jpg

      http://s11.postimg.org/ohsc9zhdd/question.jpg

      If my problem is not clear please let me know I will try to explain it better...cheers!

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

      1 Reply Last reply Reply Quote 0
      • renderizaR Offline
        renderiza
        last edited by

        I think this might be it...Sorry not very good at math πŸ˜• πŸ˜’

        Top Right = f1nx > 0 and f1ny > 0

        Top Left = f1nx < 0 and f1ny > 0

        Button Right = f1nx > 0 and f1ny < 0

        Button Left = f1nx < 0 and f1ny < 0

        [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          I'm not quite sure I understand, but I think I might have something helpful.

          Find the dot product of the face's normal and the x_axis. If its a positive number, then the face normal is in the positive x range. Do the same for the y and z (if you need z). Try this code snippet, it will tell you if the face normal is pointing in a positive or negative x,y,z direction. Or it will tell you if the face normal is perpendicular to the model x,y, or z axis.

          face=Sketchup.active_model.selection[0]
          norm = face.normal
          dot_products = {}
          dot_products["x"] = norm.dot(X_AXIS)
          dot_products["y"] = norm.dot(Y_AXIS)
          dot_products["z"] = norm.dot(Z_AXIS)
          
          dot_products.each do |key, value|
          
          case 
            when value < 0
              puts "#{key} direction is a negative direction"
            when value == 0 
              puts "#{key} direction is perpendicular to the #{key} axis"
            when value > 0
              puts "#{key} direction is a positive direction"
           end
          end
          

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • renderizaR Offline
            renderiza
            last edited by

            Thanks Chris Fullmer your example does the job as well.

            Here is another example that will select faces that are pointing to the top right...

            model = Sketchup.active_model
            sel = model.selection
            ents = model.active_entities
            faces = ents.grep(Sketchup;;Face)
            
            faces.each do |face|
            	f1nx = face.normal.x
            	f1ny = face.normal.y
            	
            	#Face looking top right 
            	if f1nx > 0 and f1ny > 0 
            		sel.add face
            	end
            end
            

            [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

            1 Reply Last reply Reply Quote 0
            • tt_suT Offline
              tt_su
              last edited by

              That image in the OP isn't loading for me...

              1 Reply Last reply Reply Quote 0
              • Rich O BrienR Online
                Rich O Brien Moderator
                last edited by

                now?

                Download the free D'oh Book for SketchUp πŸ“–

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  nope, not yet. It never showed for me either, I had to click on it to follow the link.

                  Lately you've been tan, suspicious for the winter.
                  All my Plugins I've written

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

                    No.
                    The image links aren't working... πŸ˜•

                    http://s11.postimg.org/jj4tvgdki/question.jpg

                    http://s11.postimg.org/ohsc9zhdd/question.jpg

                    http://s11.postimg.org/z4m5fepiq/question.jpg

                    Above is http://s11.postimg.org/z4m5fepiq/question.jpg NOT these...
                    http://s11.postimg.org/jj4tvgdki/question.jpg]
                    http://s11.postimg.org/ohsc9zhdd/question.jpg

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • Rich O BrienR Online
                      Rich O Brien Moderator
                      last edited by

                      I see it. NA NA NA-NA NA

                      Download the free D'oh Book for SketchUp πŸ“–

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

                        Back to the question...
                        NorthEast Quadrant: normal.y>0 normal.x>0
                        SouthEast Quadrant: normal.y<0 normal.x>0
                        SouthWest Quadrant: normal.y<0 normal.x<0
                        NorthWest Quadrant: normal.y>0 normal.x<0

                        As you said:
                        Due North: normal.y==1 normal.x==0
                        Due East: normal.y==0 normal.x==1
                        Due South: normal.y==-1 normal.x==0
                        Due West: normal.y==0 normal.x==-1

                        Exactly Vertical: normal.z==0
                        Upwards Facing: normal.z>0
                        Downwards Facing: normal.z<0
                        Exactly Up: normal.z==1
                        Exactly Down: normal.z==-1

                        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