Project a Vector3 through a 3D camera onto a Vector2?

If I understand the the API’s documentation correctly, Matrix.CreatePerspectiveFieldOfView(…) creates a Matrix that projects a Vector3 onto a 2D plane. How do I actually perform this transformation and get the resulting Vector2 projection?

Vector3.Transform(…) and Vector2.Transform(…) return a Vector3 and Vector2 respectively, so I assume they aren’t the right methods to use.

Vector3.Transform is what you want. The resulting z coordinate is the distance from the camera plane (the depth of the point), so you’re interested in the X and Y coordinates.

1 Like