Math 如何找到点在平面上的正交投影

Math 如何找到点在平面上的正交投影,math,3d,Math,3d,假设我有点(x,y,z),平面有点(a,b,c)和法线(d,e,f)。我想找到第一个点在平面上正交投影的结果。我在3d图形编程中使用它。我想在平面上实现某种剪裁。点的投影q=(x,y,z)到由点p=(a,b,c)和法线n=(d,e,f)给出的平面上是 q_proj = q - dot(q - p, n) * n 此计算假定n是单位向量。我已使用QVector3D在Qt中实现了此函数: QVector3D getPointProjectionInPlane(QVector3D point, QV

假设我有点(x,y,z),平面有点(a,b,c)和法线(d,e,f)。我想找到第一个点在平面上正交投影的结果。我在3d图形编程中使用它。我想在平面上实现某种剪裁。

点的投影
q=(x,y,z)
到由点
p=(a,b,c)
和法线
n=(d,e,f)
给出的平面上是

q_proj = q - dot(q - p, n) * n

此计算假定
n
是单位向量。

我已使用QVector3D在Qt中实现了此函数:

QVector3D getPointProjectionInPlane(QVector3D point, QVector3D planePoint, QVector3D planeNormal)
{
    //q_proj = q - dot(q - p, n) * n
    QVector3D normalizedPlaneNormal = planeNormal.normalized();
    QVector3D pointProjection = point - QVector3D::dotProduct(point - planePoint, normalizedPlaneNormal) * normalizedPlaneNormal;
    return pointProjection;
}

这使用了与前一个被接受的答案相同的算法,并且使用了一种不需要的语言。这个答案对被接受的答案又有什么补充呢?