已知四个点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();
    }
相关推荐
MechMaster4 天前
Halcon计算点到平面的距离没有那么简单
平面
ICT系统集成阿祥7 天前
华为云stack网络平面有哪些?作用及技术实现介绍!
网络·平面·华为云
liang_20269 天前
【HT周赛】T3.二维平面 题解(分块:矩形chkmax,求矩形和)
数据结构·笔记·学习·算法·平面·总结
猎板阿权14 天前
出于PCB设计层面考虑,连排半孔需要注意哪些事项?
单片机·物联网·平面
惊鸿一博15 天前
几何_平面方程表示_点+向量形式
平面
光电大美美-见合八方中国芯17 天前
【平面波导外腔激光器专题系列】1064nm单纵模平面波导外腔激光器‌
网络·数据库·人工智能·算法·平面·性能优化
青花瓷17 天前
空间内任意点到直线和平面的距离推导
数学·平面·解析几何
yuanpan18 天前
平面坐标系中判断点P是否在线段上AB上的常用方法总结
开发语言·python·平面·点线关系
白熊18818 天前
【计算机视觉】OpenCV项目实战:get_inverse_perspective:基于OpenCV的透视图转化为不同平面
opencv·计算机视觉·平面
随便昵称20 天前
码蹄集——直线切平面、圆切平面
平面