空间求平面方程,以及点到平面的距离

    //根据空间三点求平面方程
    int x1, y1, z1;
    int x2, y2, z2;
    int x3, y3, z3;
    // ->  Ax + By + Cz + D = 0 
    double A = (y2-y1)*(z3-z1)-(z2-z1)*(y3-y1);   
    double B = (x3-x1)*(z2-z1)-(x2-x1)*(z3-z1);
    double C = (x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
    double D = -(A*x1+B*y1+C*z1);


    //求空间中一点到平面的距离
    int x, y, z;
    double d = fabs(A*x+B*y+C*z+D)/(1.0*sqrt(A*A+B*B+C*C));

你可能感兴趣的:(模板)