标签:normal code mes 坐标 简介 cno amp double length
如何通过三个点计算一个平面的的方程。
A(0,1,0);
B(1,0,0);
C(1,1,0);
$$\vec{AB} = B - A = (1,-1,0)$$
$$\vec{AC} = C - A = (1,0,0)$$
\begin{equation}
\vec{AB} \times \vec{AC} =
\left(
\begin{array}{ccc}
i & j & k\
1 & -1 & 0\
1 & 0 & 0
\end{array}
\right)
=
\left(
\begin{array}{cc}
-1 & 0\
0 & 0
\end{array}
\right)_{i}
得到
a(x - x_{0}) + b(y - y_{0}) + c(z- z_{0}) = 0
==>
0(x - x_{0}) + 0(y - y_{0}) + 1(z- z_{0}) = 0
==> 带入 A 点的坐标
z = 0 即标准答案~~
void SimpleMesh::computeABCD(Mesh::Point &point1, Mesh::Point &point2, Mesh::Point &point3, double& a, double& b, double & c, double &d)
{
Mesh::Normal vecP1P2 = point2 - point1;
Mesh::Normal vecP1P3 = point3 - point1;
Mesh::Normal vecNormal = vecP1P2 % vecP1P3;
double length = getDis(vecNormal, vecNormal);
a = vecNormal[0] / length;
b = vecNormal[1] / length;
c = vecNormal[2] / length;
// 带入point1
//a * ( x - point1[0] ) + b * (y - point1[1]) + c * (z - point1[2]) = 0
d = a * (-1) * point1[0] + b * (-1) * point1[1] + c * (-1) * point1[2];
}
标签:normal code mes 坐标 简介 cno amp double length
原文地址:https://www.cnblogs.com/eat-too-much/p/11323541.html