Fork me on GitHub

精度问题——直线方程的系数判断实际生产中三点能否确定一个圆

已知三点p1(x1,y1,z1)、p2(x2,y2,z2)、p3(x3,y3,z3),求平面方程如下:

c=向量AB=向量OB-向量OA=(x2-x1,y2-y1,z2-z1)

b=向量AC=向量OC-向量OA=(x3-x1,y3-y1,z3-z1)

n=向量AB×向量AC=([y1z2-y1z3-y2z1+y2z3+y3z1-y3z2],[-x1z2+x1z3+x2z1-x2z3-x3z1+x3z2],[x1y2-x1y3-x2y1+x2y3+x3y1-x3y2])

  =(A,B,C)

即A=y1z2-y1z3-y2z1+y2z3+y3z1-y3z2,

   B=-x1z2+x1z3+x2z1-x2z3-x3z1+x3z2,

   C=x1y2-x1y3-x2y1+x2y3+x3y1-x3y2

带入(x1,y1,z1),

=>(y1z2-y1z3-y2z1+y2z3+y3z1-y3z2)x1+(-x1z2+x1z3+x2z1-x2z3-x3z1+x3z2)y1+(x1y2-x1y3-x2y1+x2y3+x3y1-x3y2)z1+d=0,

=>x1y1z2-x1y1z3-x1y2z1+x1y2z3+x1y3z1-x1y3z2-x1y1z2+x1y1z3+x2y1z1-x2y1z3-x3y1z1+x3y1z2+x1y2z1-x1y3z1-x2y1z1+x2y3z1+x3y1z1-x3y2z1+d=0,

=>x1y2z3-x1y3z2-x2y1z3+x2y3z1+x3y1z2-x3y2z1+d=0,

=>D=-x1y2z3+x1y3z2+x2y1z3-x2y3z1-x3y1z2+x3y2z1

=>Ax+By+Cz+D=0 为直线方程

此时向量AB、AC的叉积|n|=|b||c|sin<b,c>

用|n|值的大小来判断实际生产中三点能否确定一个圆:

if (A * A + B* B+ C* C < 0.0000001)
{
        MessageBox.Show("三点共线");
        return -1;
}

 

posted @ 2016-03-03 11:51  千秋此意  阅读(352)  评论(0编辑  收藏  举报