Struct LineOrPoint

Source
pub struct LineOrPoint<T: GeoNum> { /* private fields */ }
Expand description

Either a line segment or a point.

The coordinates are ordered (see SweepPoint) and a line segment must have distinct points (use the Point variant if the coordinates are the equal).

Implementations§

Source§

impl<T: GeoNum> LineOrPoint<T>

Source

pub fn is_line(&self) -> bool

Checks if the variant is a line.

Source

pub fn line(&self) -> Line<T>

Return a Line representation of self.

Source

pub fn left(&self) -> SweepPoint<T>

Source

pub fn right(&self) -> SweepPoint<T>

Source

pub fn end_points(&self) -> (SweepPoint<T>, SweepPoint<T>)

Source

pub fn new(left: SweepPoint<T>, right: SweepPoint<T>) -> Self

Source§

impl<T: GeoFloat> LineOrPoint<T>

Source

pub fn intersect_line(&self, other: &Self) -> Option<Self>

Intersect a line with self and return a point, a overlapping segment or None.

The other argument must be a line variant (debug builds will panic otherwise).

Source

pub fn intersect_line_ordered(&self, other: &Self) -> Option<Self>

Trait Implementations§

Source§

impl<T: Clone + GeoNum> Clone for LineOrPoint<T>

Source§

fn clone(&self) -> LineOrPoint<T>

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<T: GeoFloat> Cross for LineOrPoint<T>

Source§

type Scalar = T

Scalar used the coordinates.
Source§

fn line(&self) -> LineOrPoint<Self::Scalar>

The geometry associated with this type. Use a Line with the start and end coordinates to represent a point.
Source§

impl<T: GeoNum> Debug for LineOrPoint<T>

Source§

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

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

impl<T: GeoNum> From<(SweepPoint<T>, SweepPoint<T>)> for LineOrPoint<T>

Source§

fn from(pt: (SweepPoint<T>, SweepPoint<T>)) -> Self

Converts to this type from the input type.
Source§

impl<T: GeoNum> From<Coord<T>> for LineOrPoint<T>

Convert from a Coord

Source§

fn from(c: Coord<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: GeoNum> From<Line<T>> for LineOrPoint<T>

Convert from a Line ensuring end point ordering.

Source§

fn from(l: Line<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: GeoNum> From<SweepPoint<T>> for LineOrPoint<T>

Source§

fn from(pt: SweepPoint<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: GeoNum> PartialEq for LineOrPoint<T>

Equality based on ordering defined for segments as per algorithm.

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<T: GeoNum> PartialOrd for LineOrPoint<T>

Ordering defined for segments as per algorithm.

Requires the following conditions:

  1. If comparing two lines, both the left ends must be strictly smaller than both right ends.

  2. A point is treated as a infinitesimal small vertical segment centered at its coordinates.

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Copy + GeoNum> Copy for LineOrPoint<T>

Auto Trait Implementations§

§

impl<T> Freeze for LineOrPoint<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for LineOrPoint<T>
where T: RefUnwindSafe,

§

impl<T> Send for LineOrPoint<T>
where T: Send,

§

impl<T> Sync for LineOrPoint<T>
where T: Sync,

§

impl<T> Unpin for LineOrPoint<T>
where T: Unpin,

§

impl<T> UnwindSafe for LineOrPoint<T>
where T: UnwindSafe,

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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool