Skip to main content

Segment3f

Struct Segment3f 

Source
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

Source

pub fn new(start: Vec3f, end: Vec3f) -> Segment3f

Create a segment between two points

Source

pub fn to_vec3f(self) -> Vec3f

Get vector from start to end (not normalized)

Source

pub fn length(self) -> f32

Length of the line segment

Source

pub fn reversed(self) -> Segment3f

Create a copy of self with endpoints reversed.

Source

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.

Source

pub fn distance_from_parametric_delta(self, delta: f32) -> f32

Convert a parametric delta to coordinate space. The sign of the input is kept.

Source

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.

Source

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.

Source

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].

Source

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

Source

pub fn point_distance(self, point: Vec3f) -> f32

Return the distance from this segment to the input point.

Source

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

Trait Implementations§

Source§

impl Add<Vec3f> for Segment3f

Source§

type Output = Segment3f

The resulting type after applying the + operator.
Source§

fn add(self, v: Vec3f) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for Segment3f

Source§

fn clone(&self) -> Segment3f

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Segment3f

Source§

impl Debug for Segment3f

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Segment3f

Source§

fn eq(&self, other: &Segment3f) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Segment3f

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.