2012-01-20 26 views

回答

45

q = (x, y, z)的投影到由點p = (a, b, c)和正常n = (d, e, f)給定的平面內是

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

這種計算假設n是單位矢量。

0

我實現了使用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; 
} 
+0

這將使用相同的算法以前,接受的答案,並使用沒有要求的語言。這個答案是什麼增加了接受的答案? –