How do I find the orthogonal projection of a point onto a plane

后端 未结 2 473

Lets say I have point (x,y,z) and plane with point (a,b,c) and normal (d,e,f). I want to find the point that is the result of the orthogonal projection of the first point o

2条回答
  •  情话喂你
    2020-12-23 12:39

    I've implemented this function in Qt using QVector3D:

    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;
    }
    

提交回复
热议问题