• Login
sketchucation logo sketchucation
  • Login
πŸ”Œ Quick Selection | Try Didier Bur's reworked classic extension that supercharges selections in SketchUp Download

How to tell if a plane is horizontal

Scheduled Pinned Locked Moved Developers' Forum
12 Posts 6 Posters 584 Views 6 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.
  • D Offline
    daiku
    last edited by 11 Feb 2014, 01:06

    I know I'll say "duh" when someone tells me the answer, but I need to know if a plane (section_plane, actually) is horizontal.

    Clark Bremer
    http://www.northernlightstimberframing.com

    1 Reply Last reply Reply Quote 0
    • C Offline
      cotty
      last edited by 11 Feb 2014, 06:25

      I don't know ruby, but mathematically, you can control if the normal of that face is parallel to the vector (0 0 1)... does this help?

      my SketchUp gallery

      1 Reply Last reply Reply Quote 0
      • J Offline
        jeff hammond
        last edited by 11 Feb 2014, 07:34

        .

        duh πŸ˜‰

        Six_flight_instruments.JPG

        (is this a ruby question or an ill_located thead?)

        dotdotdot

        1 Reply Last reply Reply Quote 0
        • J Offline
          jolran
          last edited by 11 Feb 2014, 08:15

          If you already have required a plane called "myplane", you can get the plane normal and compare it's vector against Z-axis within some tolerance..
          I'm not sure if it suffice to simply compare 2 vectors for equality (?) due to floating Point comparison.
          BUT in this case Sketchup is creating the vector so perhaps the tolerance is set and you can compare plane_normal against Z_AXIS. Im not certain about that though..
          Depending at what the direction the normal is Pointing it might be a good idea to do a tolerance for absolute values. IE discard -1 to 1 for example. Ruby abs could be used.
          Even if the sectioncut is horisontal it might be flipped upside down. If you want to trap for that..
          So the vector direction might NOT be the same as Z-axis even if parallel.
          I'm presuming you already familiar with the API methods for comparing vectors..

          This could be used as an alternative to abs.

          
          def positivVal(a)
             a = a < 0 ? -a ; a
          end	
          
          

          Anyway.
          This should get you the plane normal. I got this code from somewhere in this forum, so there IS a thread covering this subject, somewhere..

          
          a, b, c, d = myplane
          plane_normal = Geom;;Vector3d.new(a,b,c)
          
          
          
          1 Reply Last reply Reply Quote 0
          • S Offline
            slbaumgartner
            last edited by 11 Feb 2014, 14:19

            The Geom::Vector3d#== already accounts for floating point tolerance. So, you should create a z-oriented Vector3d and compare it to the normal of the plane using ==. You should not test it to see if x and y are zero and z is 1.0, as that will not account for tolerance.

            1 Reply Last reply Reply Quote 0
            • J Offline
              jolran
              last edited by 11 Feb 2014, 17:07

              @unknownuser said:

              Geom::Vector3d#== already accounts for floating point tolerance

              Right. Good to know for sure.

              @unknownuser said:

              you should create a z-oriented Vector3d and compare it to the normal of the plane using ==

              Can't one compare against Z_AXIS ?

              Come to think of it. If using a sectioncut all geometry will be on same plane. And "probably" contains faces which could be used to extract a face normal. So a plane might not even get into use. Just compare face normal against Z_AXIS ?
              Or if Z_AXIS is not valid comparison object, create a z axis vector like Slbaumgartner said.

              Jeff πŸ˜„

              1 Reply Last reply Reply Quote 0
              • S Offline
                slbaumgartner
                last edited by 11 Feb 2014, 20:02

                @jolran said:

                Can't one compare against Z_AXIS ?

                Yes, Z_AXIS is just a pre-defined Vector3d oriented z-wards.

                @jolran said:

                Come to think of it. If using a sectioncut all geometry will be on same plane. And "probably" contains faces which could be used to extract a face normal. So a plane might not even get into use. Just compare face normal against Z_AXIS ?

                Jeff πŸ˜„

                A SectionPlane has an associated Plane, and that is all about the plane that is accessible from Ruby. It is returned by SectionPlane#get_plane as a 4-element Array. The first three elements are the components of the normal vector to the plane, and the fourth is the offset of the plane from the origin along the normal. So, you could form a Vector3D from the SectionPlane's normal and compare with that.

                However, you should realize that a SectionPlane is a display animal only - the edges you see displayed are not DrawingEntities and do not exist in any Entities collection of the model. You will not find any Faces to use for determining normal vectors! There are plugins that will generate the DrawingEntities of the cut, but this is not done by a SectionPlane.

                Steve

                1 Reply Last reply Reply Quote 0
                • J Offline
                  jolran
                  last edited by 11 Feb 2014, 21:00

                  Ah, yeah! Youre right off course. I was thinking of a sectioncut, when it's a sectionplane were dealing with, Doh! Should read the topics better hereafter..

                  Thanks for the lesson. I Think the TO should manage now.

                  1 Reply Last reply Reply Quote 0
                  • P Offline
                    pbacot
                    last edited by 11 Feb 2014, 21:09

                    nvm

                    MacOSX MojaveSketchUp Pro v19 Twilight v2 Thea v3 PowerCADD

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      daiku
                      last edited by 12 Feb 2014, 01:26

                      Vector normal to the plane seems to simply be the first 3 elements of the 4 that denote a plane. Thanks everyone. CB.

                      Clark Bremer
                      http://www.northernlightstimberframing.com

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        daiku
                        last edited by 14 Feb 2014, 00:26

                        @jeff hammond said:

                        .

                        (is this a ruby question or an ill_located thead?)

                        Am I not in the developers forum?

                        Clark Bremer
                        http://www.northernlightstimberframing.com

                        1 Reply Last reply Reply Quote 0
                        • J Offline
                          jeff hammond
                          last edited by 14 Feb 2014, 00:54

                          @daiku said:

                          @jeff hammond said:

                          .

                          (is this a ruby question or an ill_located thead?)

                          Am I not in the developers forum?

                          yes, you are.
                          every thread isn't always started in the right forum though and your question could be answered in a sketchup way or a ruby way.. the first answer to your question was how to figure it out in sketchup.

                          hence my question.

                          [+, many members (myself included) browse the forums via the 'new posts' or 'active topics' lists so sub-forums aren't always so obvious since we're basically seeing all forums in one view.. some confusion is bound to happen here&there.. it's ok]

                          dotdotdot

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

                          Advertisement