已知四个点ABPQ,求Q点在ABP平面的投影点。如果已经共面了,投影点和Q重合

投影点设为M,则有向量QM,ABP的法向 和QM是平行的。

平面的方程为 Ax+By+Cz+D=0;

cpp 复制代码
    //* \author  PangYeYi
  //   *  \return Q2 在 P1 P2 Q1 构成的平面的上的投影点
  //   ******************/
    Point3d VEC3::GetProPointOn_Face(const Point3d& P1, const Point3d& P2, const Point3d& Q1, const Point3d& Q2)
    {

        UGAPI::StrPoint P(P1);
        UGAPI::StrPoint Q(P2);
        UGAPI::StrPoint A(Q1);
        UGAPI::StrPoint B(Q2);
        UGAPI::StrPoint PQ = Q - P;
        UGAPI::StrPoint PA = A - P;
        UGAPI::StrPoint normal = PQ.cross(PA);// 法向 叉乘 

      
   
        double D = 0;
        if (normal.point[0] == 0 && normal.point[1] == 0 && normal.point[2] == 0)//平行
        {
            return Point3d(0, 0, 0);

        }
        else
        {    //平面方程  Ax+By+Cz+D=0;  A  B  C 为法向 
            D = (normal.point[0] * P1.X + normal.point[1] * P1.Y + normal.point[2] * P1.Z) * (-1);
        }

     
        double t = normal.point[0] * Q2.X + normal.point[1] * Q2.Y + normal.point[2] * Q2.Z + D;

        //平面法向量 normal 的模长的平方
        double T = normal.point[0] * normal.point[0] + normal.point[1] * normal.point[1] + normal.point[2] * normal.point[2];
      
        UGAPI::StrPoint  res = B + normal * ((-t) / T);// 比例

        return res.ToPoint3d();
    }
相关推荐
视觉人机器视觉5 天前
什么是平面环形无影光源
人工智能·计算机视觉·平面·3d·c#·视觉检测
UI设计兰亭妙微7 天前
以用户为中心,汽车 HMI 界面设计的创新之道
ui·平面·汽车·用户界面
csdn_aspnet1 个月前
c++ 给定欧氏平面中的一组线可以形成的三角形的数量
c++·算法·平面
csdn_aspnet1 个月前
C# 给定欧氏平面中的一组线可以形成的三角形的数量
算法·平面·c#
不二青衣1 个月前
利用平面进行位姿约束优化
算法·平面
昵称难产中1 个月前
浅谈计算机网络02 | SDN控制平面
网络协议·计算机网络·平面·云计算·信息与通信
不二青衣1 个月前
使用gtsam添加OrientedPlane3Factor平面约束因子
人工智能·算法·平面
昵称难产中1 个月前
浅谈计算机网络01 | SDN数据平面
网络·计算机网络·平面
红黑色的圣西罗2 个月前
Unity 中计算射线和平面相交距离的原理
平面·unity·游戏引擎
Pipi_Xia_2 个月前
相切于球体上定点的平面
线性代数·算法·平面·几何学