當給定從點到一個平面的距離時。該點現在可以位於與第一個平面相距預定距離的平面內的任意點上,因此您可以將該位置從3維範圍內的任何位置縮小到第三維僅具有2維的這些子集的任何位置..
當您給出從點到第二個平面的距離。你現在有了同樣的信息,這是一個可以達到的點。你會注意到這兩個平原相交併形成一條線。沒有必要存儲這條線。只要知道你已經將可能點的位置縮小到1維。
最後給出從點到第三平面的距離。您可以在距原始平面定義的距離上創建新平面,並且該平面應與其他2個新平面相交。所有三架飛機將在一點相交,這將是該點的位置。
謝天謝地,我們可以添加到平面矢量的距離,以創建新的平面。然後,我們可以通過使用每個飛機的相關尺寸來獲得該點的位置,以獲得該點的位置。
public static Vector3 RealWorldSpaceToOtherSpace(Vector3 realspace, Vector4 clipplane)
{
// Work out the normal vectors of 3 imaginary planes
Vector3 floor = new Vector3(clipplane.X, clipplane.Y, clipplane.Z);
Vector3 centre = new Vector3(1f, -clipplane.X/clipplane.Y, 0f);
Vector3 wall = Vector3.Cross(floor, centre);
// Get distances from the planes
// Distance is represented as a Vector, since it needs to hold
// the direction in 3d space.
Vector3 distanceToFloor = new Vector3(0f, realspace.y ,0f,);
Vector3 distanceToCentre = new Vector3( realspace.x ,0f,0f,);
Vector3 distanceToWall = new Vector3(0f,0f, realspace.z);
// Create planes that contain all the possible positions of the point
// based on the distance from point to the corresponding plane.
Vector3 pointY = floor + distanceToFloor;
Vector3 pointX = centre + distanceToCentre;
Vector3 pointZ = wall + distanceToWall;
// Now that we have all 3 point's dimensions, we can create a new vector that will hold its position.
Vector3 point = new Vector3(pointX.x,pointY.y, pointZ.z);
return point
}
請注意,在Unity中有一個plane結構。
噢!謝謝!! –