Four point plane to Point+Vector Plane?
-
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"

-
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.)
-
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. -
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 beGeom::Vector3d.new(a,b,c)?
But what isd? And I don't see where I derive any point3d from this - to fit[ point3d, vector3d ]... -
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] -
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.
-
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] endWhen 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)] -
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.
-
Also you really don't want 4 points as input as they may not be coplanar. 3 points are guaranteed to be coplanar.
-
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 theGeommodule says planes can be in either format.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement