I've got a arbitrary collection of 3d points, i know they're coplanar,开发者_高级运维 but how do i calculate that plane?
Take any three distinct points, and form a triangle of non-zero area. Compute the cross product of two of the triangle's sides. That gives you the plane's normal, and you can use the common point as a point on the plane.
A point on a plane plus a normal defines a plane.
If they're not all planar, calculate the coefficients of the plane using a least squares fit.
The equation for a plane is Ax + By + Cz = D, so plug in your points and solve for the four unknown coefficients.
UPDATE: Just curious - how do you "know" that all the points are in the same plane? What makes you so certain?
Assuming that they are co-planar, pick three points, and try this:
http://www.jtaylor1142001.net/calcjat/Solutions/VPlanes/VP3Pts.htm
Because any three non-colinear points define a plane, a possible answer is...
Simply grab the first three points that are not colinear.
Another way to define a plane is a function from two parameters to a point. If you have three points A,B,C, then the function f(i,j) = A + (B-A)i + (C-A)j
covers all the points on the plane.
Depending on your application it may be useful to normalise the b = (B-A)
and c = (C-A)
vectors to be perpendicular and of unit length. Unit length is easy.
In order to make them perpendicular, first normalise b, then take the dot product of b and c. This is the amount the the c vector points in the same direction as b, so substract this from c. c = c - (b.c)b
Finally normalise c (i.e. divide by it's length)
精彩评论