Expand description
A ray in 3-dimensional space: a line through space with a starting point and a direction.
Any point on the ray can be found through the formula origin + t * dir,
where t is a non-negative floating point value, which represents the distance
along the ray.
Fields
origin: Vec3Start of the ray
dir: Vec3Direction of the ray, normalized
Implementations
sourceimpl Ray3
impl Ray3
sourcepub const ZERO: Ray3 = Self{ origin: Vec3::ZERO, dir: Vec3::ZERO,}
pub const ZERO: Ray3 = Self{ origin: Vec3::ZERO, dir: Vec3::ZERO,}
An invalid ray, starting at the origin and going nowhere.
sourcepub fn from_origin_dir(origin: Vec3, dir: Vec3) -> Ray3
pub fn from_origin_dir(origin: Vec3, dir: Vec3) -> Ray3
dir should be normalized
sourcepub fn offset_along_ray(&self, t: f32) -> Ray3
pub fn offset_along_ray(&self, t: f32) -> Ray3
Returns a new ray that has had its origin moved a given distance forwards along the ray.
If the ray direction is normalized then the t parameter corresponds to the world space distance it moves.
pub fn point_along(&self, t: f32) -> Vec3
sourcepub fn closest_points(&self, other: &Ray3) -> (Vec3, Vec3)
pub fn closest_points(&self, other: &Ray3) -> (Vec3, Vec3)
Returns the line segment where self and other are the closest to each other.
If the rays are parallel then non-finite points are returned.
sourcepub fn closest_ts(&self, other: &Ray3) -> (f32, f32)
pub fn closest_ts(&self, other: &Ray3) -> (f32, f32)
Returns the distance along both rays which together form
line segment where self and other are the closest to each other.
If the rays are parallel then non-finite values are returned.
sourcepub fn intersects_plane(&self, plane: Plane3) -> Vec3
pub fn intersects_plane(&self, plane: Plane3) -> Vec3
Returns the point where the ray intersects the plane. Returns non-finite result of the ray and plane are parallel.
pub fn closest_t_to_point(&self, point: Vec3) -> f32
sourcepub fn closest_point_to_point(&self, point: Vec3) -> Vec3
pub fn closest_point_to_point(&self, point: Vec3) -> Vec3
Returns the point along the ray that is closest to the given point. The returned point may be “behind” the ray origin.