sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Four point plane to Point+Vector Plane?

    Scheduled Pinned Locked Moved Developers' Forum
    10 Posts 3 Posters 751 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.
    • thomthomT Offline
      thomthom
      last edited by

      http://code.google.com/apis/sketchup/docs/ourdoc/geom.html#introduction

      @unknownuser said:

      A plane can be represented as either an Array of a point and a vector, or as an Array of 4 numbers that give the coefficients of a plane equation.

      How does one convert a plane defined by four points to a plane defined by [ point3d, vector3d ] ?

      "coefficients of a plane equation" ❓

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

      1 Reply Last reply Reply Quote 0
      • R Offline
        remus
        last edited by

        Just a small correction, when you say "a plane defined by 4 points" you really mean a plane defined by 4 numbers (which are the coefficients of the equation of the plane.)

        http://remusrendering.wordpress.com/

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

          hmm... 😳 always read "numbers" as "Point3d"s...
          I never used or encountered anything other than the [ point3d, vector3d ] variant, but I want to make a method to ensure that's the format I get planes in.

          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

            http://local.wasp.uwa.edu.au/~pbourke/geometry/planeeq/

            @unknownuser said:

            The standard equation of a plane in 3 space is Ax + By + Cz + D = 0

            @unknownuser said:

            The normal to the plane is the vector (A,B,C).

            So given a plane of [a,b,c,d], the normal would be Geom::Vector3d.new(a,b,c)?
            But what is d ? And I don't see where I derive any point3d from this - to fit [ point3d, vector3d ] ...

            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

              Think it makes sense now....

              Did some testing:

              
              p1 = [200,200,200]
              [200, 200, 200]
              p2 = [400,200,200]
              [400, 200, 200]
              p3 = [400,400,200]
              [400, 400, 200]
              p4 = [200,400,200]
              [200, 400, 200]
              Geom.fit_plane_to_points(p1,p2,p3,p4)
              [-0.0, -0.0, 1.0, -200.0]
              
              

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

              1 Reply Last reply Reply Quote 0
              • R Offline
                remus
                last edited by

                d is just a constant, so unless theres an error in the docs (i.e. they mean 'you can define a plane with a vector and a constant', not unlikely) then youll have to find a point on the plane.

                http://remusrendering.wordpress.com/

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

                  This seem to work.

                  
                  	# Return a plane in the format [ point3d, vector3d ]
                  	def self.normalize_plane(plane)
                  		return plane if plane.length == 2
                  		a, b, c, d = plane
                  		v = Geom;;Vector3d.new(a,b,c)
                  		p = ORIGIN.offset(v.reverse, d)
                  		return [p, v]
                  	end
                  
                  

                  When I test it:

                  
                  p1 = [200,200,200]
                  [200, 200, 200]
                  p2 = [400,200,200]
                  [400, 200, 200]
                  p3 = [400,400,200]
                  [400, 400, 200]
                  p4 = [200,400,200]
                  [200, 400, 200]
                  plane = Geom.fit_plane_to_points(p1,p2,p3,p4)
                  [-0.0, -0.0, 1.0, -200.0]
                  TT_Lib;;Geom3D.normalize_plane(plane)
                  [Point3d(0, 0, 200), Vector3d(0, 0, 1)]
                  
                  

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

                  1 Reply Last reply Reply Quote 0
                  • AdamBA Offline
                    AdamB
                    last edited by

                    Its just not efficient. A plane is commonly defined by a direction and a distance along that direction (the "D" constant). Keep in mind a plane is infinite so you just need "a point" - any point on the plane to define it.

                    So explicitly storing the Point3d is (groan) pointless. If you want a point on the plane from its plane equation you just do:

                    plane_normal.scale(D)

                    ie You just need to store 4 values not 6 as you are doing.

                    Developer of LightUp Click for website

                    1 Reply Last reply Reply Quote 0
                    • AdamBA Offline
                      AdamB
                      last edited by

                      Also you really don't want 4 points as input as they may not be coplanar. 3 points are guaranteed to be coplanar.

                      Developer of LightUp Click for website

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

                        Yea - I'm not dealing with points. As remus pointed out to me, it was four numbers. I just wanted a method that'd convert a plane defined as four numbers into [ point3d, vector3d ] - as the Geom module says planes can be in either format.

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

                        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