Skip to main content

Edge

Struct Edge 

Source
pub struct Edge<T> {
    pub start: Point<T>,
    pub end: Point<T>,
}
Expand description

An edge (line segment) is represented by its starting point and end point.

Fields§

§start: Point<T>§end: Point<T>

Implementations§

Source§

impl<T: Copy> Edge<T>

Source

pub fn new(start: impl Into<Point<T>>, end: impl Into<Point<T>>) -> Self

Source

pub fn reversed(&self) -> Self

Return the same edge but with the two points swapped.

Source§

impl<T: PartialEq> Edge<T>

Source

pub fn is_degenerate(&self) -> bool

Check if edge is degenerate. An edge is degenerate if start point == end point.

Source

pub fn is_rectilinear(&self) -> bool

Source

pub fn is_horizontal(&self) -> bool

Source

pub fn is_vertical(&self) -> bool

Source§

impl<T: CoordType> Edge<T>

Source

pub fn vec2(&self) -> Vec2<T>

Returns the vec2 from self.start to self.end.

Source

pub fn side_of(&self, point: Point<T>) -> Side

Tells on which side of the edge a point is.

§Panics

Panics if the edge is degenerate.

Returns Side::Left if the point is on the left side, Side::Right if the point is on the right side or Side::Center if the point lies exactly on the line.

Source

pub fn contains_point(&self, point: Point<T>) -> Contains

Test if point lies on the edge. Includes start and end points of edge.

Source

pub fn line_contains_point(&self, point: Point<T>) -> bool

Test if point lies on the line defined by the edge.

Source

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

if two edges are parallel.

Source

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

if two edges are collinear, i.e. are on the same line.

Source

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

Test edges for coincidence. Two edges are coincident if they are oriented the same way and share more than one point (implies that they must be parallel).

Source

pub fn is_parallel_approx(&self, other: &Self, epsilon_squared: T) -> bool

Test if two edges are approximately parallel. To be used for float coordinates. Inspired by algorithm on page 241 of “Geometric Tools for Computer Graphics”.

Source

pub fn is_collinear_approx(&self, other: &Self, epsilon_squared: T) -> bool

Test if two edges are approximately collinear, i.e. are on the same line. Inspired by algorithm on page 241 of “Geometric Tools for Computer Graphics”.

Source

pub fn lines_intersect_approx(&self, other: &Self, epsilon_squared: T) -> bool

Test if lines defined by the edges intersect. If the lines are collinear they are also considered intersecting.

Source

pub fn crossed_by_line(&self, other: &Self) -> Contains

Test if this edge is crossed by the line defined by the other edge.

Returns WithinBounds if start and end point of this edge lie on different sides of the line defined by the other edge or OnBounds if at least one of the points lies on the line.

Source

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

Test if lines defined by the edges intersect. If the lines are collinear they are also considered intersecting.

Trait Implementations§

Source§

impl<T: Copy + PartialOrd> BoundingBox<T> for Edge<T>

Source§

fn bounding_box(&self) -> Rect<T>

Source§

impl<Src: Copy + NumCast, Dst: Copy + NumCast> Cast<Src, Dst> for Edge<Src>

Source§

type Output = Edge<Dst>

Source§

fn try_cast(&self) -> Option<Self::Output>

Source§

fn cast(&self) -> Self::Output

Source§

impl<T: Clone> Clone for Edge<T>

Source§

fn clone(&self) -> Self

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<T: Copy> Copy for Edge<T>

Source§

impl<T: Debug> Debug for Edge<T>

Source§

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

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

impl<T: Eq> Eq for Edge<T>

Source§

impl<T: Copy> From<&Edge<T>> for (Point<T>, Point<T>)

Source§

fn from(e: &Edge<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: CoordType> From<(Point<T>, Point<T>)> for Edge<T>

Source§

fn from(points: (Point<T>, Point<T>)) -> Self

Converts to this type from the input type.
Source§

impl<T: Copy> From<Edge<T>> for (Point<T>, Point<T>)

Source§

fn from(e: Edge<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<Edge<T>> for Geometry<T>

Source§

fn from(x: Edge<T>) -> Geometry<T>

Converts to this type from the input type.
Source§

impl<T: CoordType> From<[Point<T>; 2]> for Edge<T>

Source§

fn from(points: [Point<T>; 2]) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Edge<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Copy> MapPoint<T> for Edge<T>

Source§

fn transform<F>(&self, transformate: F) -> Self
where F: Fn(Point<T>) -> Point<T>,

Source§

impl<T: PartialEq> PartialEq for Edge<T>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Edge<T>

Source§

impl<T: Copy + PartialOrd> TryBoundingBox<T> for Edge<T>

Auto Trait Implementations§

§

impl<T> Freeze for Edge<T>
where Point<T>: Freeze,

§

impl<T> RefUnwindSafe for Edge<T>
where Point<T>: RefUnwindSafe,

§

impl<T> Send for Edge<T>
where Point<T>: Send,

§

impl<T> Sync for Edge<T>
where Point<T>: Sync,

§

impl<T> Unpin for Edge<T>
where Point<T>: Unpin,

§

impl<T> UnsafeUnpin for Edge<T>
where Point<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Edge<T>
where Point<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<S, T> Mirror<T> for S
where T: Copy + Zero + Sub<Output = T>, S: MapPoint<T>,

Source§

fn mirror_x(&self) -> S

Source§

fn mirror_y(&self) -> S

Source§

impl<S, T> Rotate<T> for S
where T: Copy + Zero + Sub<Output = T>, S: MapPoint<T>,

Source§

fn rotate(&self, a: Angle) -> S

Source§

impl<S, T> Scale<T> for S
where T: Copy + Mul<Output = T>, S: MapPoint<T>,

Source§

fn scale(&self, factor: T) -> S

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<S, T> Translate<T> for S
where T: Copy + Add<Output = T>, S: MapPoint<T>,

Source§

fn translate(&self, v: Vec2<T>) -> S

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.