已知四个点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();
    }
相关推荐
不吃辣49011 天前
从0-1学习导航页面布局优化和搭建
ui·平面·前端框架
海清河宴13 天前
平面直线和曲线以及空间曲线计算方法
平面
Σίσυφος190018 天前
激光三角 光平面标定之后计算深度图
算法·平面
weixin_4554725721 天前
好用的平衡机源头厂家
平面
AI科技星23 天前
基于超复数广义分形流形的电磁耦合与缪子反常磁矩几何理论
开发语言·平面·重构·概率论·量子计算·乖乖数学·全域数学
weixin_4554725724 天前
毛滚平衡机
平面
Hali_Botebie24 天前
Normalizing flows和经典的 Planar Flow(平面流) 为例
平面
weixin_4554725724 天前
高速电机平衡机
平面
AI科技星24 天前
精细结构常数 α 全套自洽公式体系(论文定稿版)
开发语言·平面·重构·概率论·量子计算
AI科技星24 天前
超复数全域分形四维/八维超立方体框架下四种基本相互作用的维度正交性与特征作用距离解析推导
开发语言·平面·重构·概率论·量子计算