Struct dumbmath::segment::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

§

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 copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Segment3f

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> 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,

§

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>,

§

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>,

§

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.