pub enum LineOrPoint<T: GeoNum> {
    Point(SweepPoint<T>),
    Line {
        left: SweepPoint<T>,
        right: SweepPoint<T>,
    },
}
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).

Variants§

§

Point(SweepPoint<T>)

§

Line

Fields

§left: SweepPoint<T>
§right: SweepPoint<T>

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

pub fn orient2d(&self, other: Coord<T>) -> Orientation

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>

§

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((start, end): (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

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

This method 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

This method 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

This method 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

This method 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> 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> 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.
source§

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

source§

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