struct Ray

A position and a direction indicating a ray through space! This is a great tool for intersection testing with geometrical shapes.

Instance Fields and Properties

Vec3 direction The direction the ray is facing, typically does not require being a unit vector, or normalized direction.
Vec3 position The position or origin point of the Ray.

Instance Methods

Ray Basic initialization constructor! Just copies the parameters into the fields.
At Gets a point along the ray! This is basically just position + direction*percent. If Ray.direction is normalized, then percent is functionally distance, and can be used to find the point a certain distance out along the ray.
Closest Calculates the point on the Ray that’s closest to the given point! This can be in front of, or behind the ray’s starting position.
Intersect Checks the intersection of this ray with a plane!
ToString Mostly for debug purposes, this is a decent way to log or inspect the Ray in debug mode. Looks like “[position], [direction]”

Static Methods

FromTo A convenience function that creates a ray from point a, towards point b. Resulting direction is not normalized.

Found an issue with these docs, or have some additional questions? Create an Issue on Github!