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: PartialEq> Edge<T>
impl<T: PartialEq> Edge<T>
Sourcepub fn is_degenerate(&self) -> bool
pub fn is_degenerate(&self) -> bool
Check if edge is degenerate. An edge is degenerate if start point == end point.
pub fn is_rectilinear(&self) -> bool
pub fn is_horizontal(&self) -> bool
pub fn is_vertical(&self) -> bool
Source§impl<T: CoordType> Edge<T>
impl<T: CoordType> Edge<T>
Sourcepub fn side_of(&self, point: Point<T>) -> Side
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.
Sourcepub fn contains_point(&self, point: Point<T>) -> Contains
pub fn contains_point(&self, point: Point<T>) -> Contains
Test if point lies on the edge. Includes start and end points of edge.
Sourcepub fn line_contains_point(&self, point: Point<T>) -> bool
pub fn line_contains_point(&self, point: Point<T>) -> bool
Test if point lies on the line defined by the edge.
Sourcepub fn is_parallel(&self, other: &Self) -> bool
pub fn is_parallel(&self, other: &Self) -> bool
if two edges are parallel.
Sourcepub fn is_collinear(&self, other: &Self) -> bool
pub fn is_collinear(&self, other: &Self) -> bool
if two edges are collinear, i.e. are on the same line.
Sourcepub fn is_coincident(&self, other: &Self) -> bool
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).
Sourcepub fn is_parallel_approx(&self, other: &Self, epsilon_squared: T) -> bool
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”.
Sourcepub fn is_collinear_approx(&self, other: &Self, epsilon_squared: T) -> bool
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”.
Sourcepub fn lines_intersect_approx(&self, other: &Self, epsilon_squared: T) -> bool
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.
Sourcepub fn crossed_by_line(&self, other: &Self) -> Contains
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.
Sourcepub fn lines_intersect(&self, other: &Self) -> bool
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>
impl<T: Copy + PartialOrd> BoundingBox<T> for Edge<T>
fn bounding_box(&self) -> Rect<T>
Source§impl<T: Copy + PartialOrd> TryBoundingBox<T> for Edge<T>
impl<T: Copy + PartialOrd> TryBoundingBox<T> for Edge<T>
fn try_bounding_box(&self) -> Option<Rect<T>>
impl<T: Copy> Copy for Edge<T>
impl<T: Eq> Eq for Edge<T>
impl<T> StructuralPartialEq for Edge<T>
Auto Trait Implementations§
impl<T> Freeze for Edge<T>where
T: Freeze,
impl<T> RefUnwindSafe for Edge<T>where
T: RefUnwindSafe,
impl<T> Send for Edge<T>where
T: Send,
impl<T> Sync for Edge<T>where
T: Sync,
impl<T> Unpin for Edge<T>where
T: Unpin,
impl<T> UnwindSafe for Edge<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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