假設有一個點Vector3 point和一個平面,平面的法向量為Vector3 planeNormal,且平面上存在一個點Vector3 planePoint。則以下程式碼求point在平面上的投影點Vector3 project:
float distance = Vector3.Dot(planeNormal, (point - planePoint));
distance *= -1;
Vector3 vectorNormalized = Vector3.Normalize(planeNormal);
Vector3 translationVector = vectorNormalized *= distance;
Vector3 project = point + translationVector;