``````a * (x - x1) + b * (y - y1) + c * (z - z1) = 0;
d = -a * x1 - b * y1 - c * z1;
``````

``````a * x + b * y + c * z + d=0;
``````

``````//已知3点坐标，求平面ax+by+cz+d=0;
void get_panel(Point p1, Point p2, Point p3, double &a, double &b, double &c, double &d)
{
a = ( (p2.y - p1.y) * (p3.z - p1.z) - (p2.z - p1.z) * (p3.y - p1.y) );

b = ( (p2.z - p1.z) * (p3.x - p1.x) - (p2.x - p1.x) * (p3.z - p1.z) );

c = ( (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x) );

d = ( 0 - (a * p1.x + b * p1.y + c * p1.z) );
}

// 已知三点坐标，求法向量
Vec3 get_Normal(Point p1, Point p2, Point p3)
{
double a = ( (p2.y - p1.y) * (p3.z - p1.z) - (p2.z - p1.z) * (p3.y - p1.y) );

double b = ( (p2.z - p1.z) * (p3.x - p1.x) - (p2.x - p1.x) * (p3.z - p1.z) );

double c = ( (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x) );

return Vec3(a, b, c);
}

//点到平面距离
double dis_pt2panel(Point pt, double a, double b, double c, double d)
{
return f_abs(a * pt.x + b * pt.y + c * pt.z + d) / sqrt(a * a + b * b + c * c);
}
``````
##### 参考

http://blog.csdn.net/pvpishard/article/details/7912511

Distance from point to plane
http://mathinsight.org/distance_point_plane