如何确定一组点是否在同一个平面上?

4
我有一组点的坐标(X,Y,Z)。我需要检查它们是否在某种公差范围内共面。我的方法是:将所有点从全局坐标系转换到本地坐标系,其中本地x,y在由集合中的3个点定义的平面上,z垂直于该平面。然后,我只需要检查集合中的所有点是否具有大致相似的本地z值。
但是,棘手的部分是如何选择3个点来定义参考平面。如果随机选择,这将导致有时点集共面,有时不共面。您有什么建议吗?
2个回答

3

1
  1. normal n

    pick any 3 points from your dataset that are not on a single line let call them p0,p1,p2. To improve accuracy they should be more distant to each other. Now to construct a normal vector do this:

    n = cross( p1-p0 , p2-p0 ); // perpendicular vector to both operands of cross
    n /= |n|;                   // unit vector
    
  2. check all points

    for any point on the plane formed by p0,p1,p2 the altitude component (in normal direction) should be zero so for any point p:

    |dot( p-p0 , n )|<=1e-10
    

    the 1e-10 is just some zero threshold due to accuracy loss on FPU ... Any point not satisfying the condition does not belong to the plane ...

那么如何选择三个点形成一个三角形?
1. 选择p0和p1 选择具有最小x、y、z坐标的点p0和具有最大x、y、z坐标的点p1。这样可以确保它们之间的距离足够远。
2. 选择p2 现在搜索点并找到使| dot(p1-p0,pi-p0)|最小的点。同时,保证| pi-p0 |不为零且足够大(例如至少为0.1 * | p1-p0 |)。这确保了点形成一个三角形并且彼此之间不会太接近。
所有这些都可以在O(n)时间内完成,因此速度仍然很快...

这不就是我在问题中描述的吗?这里的问题实际上是选择p1、p2和p3所使用的标准是什么。这非常棘手,因为例如,如果所有点都共面但p3不共面,则选择将导致错误的结果。 - N.T.C
@N.T.C 是的,你说得对,抱歉我忘记提交答案的另一部分了...我真是太傻了 :) - Spektre

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接