pub struct Segment3f {
pub start: Vec3f,
pub end: Vec3f,
}
Expand description
Line segment between two points
Fields§
§start: Vec3f
§end: Vec3f
Implementations§
source§impl Segment3f
impl Segment3f
sourcepub fn distance_to_parametric_delta(self, distance: f32) -> f32
pub fn distance_to_parametric_delta(self, distance: f32) -> f32
Convert a distance in coordinate space to a distance in the line segment’s parametric space. The sign of the input is kept.
sourcepub fn distance_from_parametric_delta(self, delta: f32) -> f32
pub fn distance_from_parametric_delta(self, delta: f32) -> f32
Convert a parametric delta to coordinate space. The sign of the input is kept.
sourcepub fn point_from_parametric(self, t: f32) -> Vec3f
pub fn point_from_parametric(self, t: f32) -> Vec3f
Linearly interpolate between the segment’s endpoints by the
factor t
. When t
is zero the result is self.start
, and
when t
is one the result is self.end
. The range of t
is
not clamped.
sourcepub fn segment_from_parametric_range(self, r: Rangef) -> Segment3f
pub fn segment_from_parametric_range(self, r: Rangef) -> Segment3f
Treat the range’s start and end as parametric coords. Use
point_from_parametric
to interpolate the range into a new
segment. The output segment is not clamped.
sourcepub fn project_segment_as_range(self, other: Segment3f) -> Rangef
pub fn project_segment_as_range(self, other: Segment3f) -> Rangef
Project another segment onto self
. The result is a
parametric range of self
clamped to [0, 1].
sourcepub fn point_distance_squared(self, point: Vec3f) -> f32
pub fn point_distance_squared(self, point: Vec3f) -> f32
Return the squared distance from this segment to the input
point
.
Adapted from “Real-Time Collision Detection” by Christer Ericson, published by Morgan Kaufmann Publishers, Copyright 2005 Elsevier Inc
sourcepub fn point_distance(self, point: Vec3f) -> f32
pub fn point_distance(self, point: Vec3f) -> f32
Return the distance from this segment to the input point
.
sourcepub fn closest_point_to_point(self, point: Vec3f) -> (f32, Vec3f)
pub fn closest_point_to_point(self, point: Vec3f) -> (f32, Vec3f)
Find the point on the segment closest to the input point. The return value contains both the parametric and actual location of the closest point.
Adapted from “Real-Time Collision Detection” by Christer Ericson, published by Morgan Kaufmann Publishers, Copyright 2005 Elsevier Inc