Description
The Project
method of the Ray
struct calculates a point along the ray at a specified distance from the ray's origin. This method is useful for determining a position in 3D space that lies on the ray, given a certain distance from the starting point.
Usage
To use the Project
method, you need to have an instance of the Ray
struct. Call the method with a float
value representing the distance from the ray's origin. The method returns a Vector3
representing the point on the ray at the specified distance.
Example
// Create a Ray with a specific origin and direction
Ray ray = new Ray
{
Position = new Vector3(0, 0, 0),
Forward = new Vector3(0, 0, 1)
};
// Project a point 10 units along the ray
Vector3 point = ray.Project(10.0f);
// Output the projected point
// Expected output: (0, 0, 10)
// This indicates the point is 10 units away from the origin along the ray's direction