Struct libreda_db::prelude::REdge
source · [−]pub struct REdge<T> {
pub start: T,
pub end: T,
pub offset: T,
pub orientation: REdgeOrientation,
}
Expand description
An rectilinear edge (horizontal or vertical line segment) is represented by its starting point and end point.
Fields
start: T
Start-coordinate of the edge.
end: T
End-coordinate of the edge.
offset: T
Distance to to the origin (0, 0).
orientation: REdgeOrientation
Orientation: Either horizontal or vertical.
Implementations
sourceimpl<T> REdge<T>
impl<T> REdge<T>
sourcepub fn new_raw(
start: T,
end: T,
offset: T,
orientation: REdgeOrientation
) -> REdge<T>
pub fn new_raw(
start: T,
end: T,
offset: T,
orientation: REdgeOrientation
) -> REdge<T>
Create a new rectilinear edge.
Parameters
start
: Start-coordinate of the edge.end
: End-coordinate of the edge.offset
: Distance to to the origin (0, 0).orientation
: Orientation: Either horizontal or vertical.
sourceimpl<T> REdge<T> where
T: PartialEq<T>,
impl<T> REdge<T> where
T: PartialEq<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 and end point are equal.
sourcepub fn is_horizontal(&self) -> bool
pub fn is_horizontal(&self) -> bool
Test if this edge is horizontal.
sourcepub fn is_vertical(&self) -> bool
pub fn is_vertical(&self) -> bool
Test if this edge is vertical.
sourceimpl<T> REdge<T> where
T: PartialOrd<T> + Sub<T, Output = T> + Copy,
impl<T> REdge<T> where
T: PartialOrd<T> + Sub<T, Output = T> + Copy,
sourceimpl<T> REdge<T> where
T: CoordinateType,
impl<T> REdge<T> where
T: CoordinateType,
sourcepub fn new<C>(start: C, end: C) -> REdge<T> where
C: Into<Point<T>>,
pub fn new<C>(start: C, end: C) -> REdge<T> where
C: Into<Point<T>>,
Create a new REdge
from two arguments that implement Into<Point>
.
The two points must lie either on a vertical or horizontal line, otherwise None
is returned.
Panics
Panics if the two points are not on the same horizontal or vertical line.
sourcepub fn try_from_points<C>(start: C, end: C) -> Option<REdge<T>> where
C: Into<Point<T>>,
pub fn try_from_points<C>(start: C, end: C) -> Option<REdge<T>> where
C: Into<Point<T>>,
Create a new REdge
from two arguments that implement Into<Point>
.
The two points must lie either on a vertical or horizontal line, otherwise None
is returned.
sourcepub fn direction(&self) -> Option<Vector<T>>
pub fn direction(&self) -> Option<Vector<T>>
Get a vector of unit length pointing in the same direction as the edge.
Returns None
if the length of the edge is zero.
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 manhattan_distance_to_point(self, p: Point<T>) -> T
pub fn manhattan_distance_to_point(self, p: Point<T>) -> T
Compute the manhattan distance of a point to the edge.
sourcepub fn contains_point(&self, point: Point<T>) -> ContainsResult
pub fn contains_point(&self, point: Point<T>) -> ContainsResult
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: &REdge<T>) -> bool
pub fn is_parallel(&self, other: &REdge<T>) -> bool
Test if two edges are parallel.
sourcepub fn is_collinear(&self, other: &REdge<T>) -> bool where
T: CoordinateType,
pub fn is_collinear(&self, other: &REdge<T>) -> bool where
T: CoordinateType,
Test if two edges are collinear, i.e. are on the same line.
sourcepub fn is_coincident(&self, other: &REdge<T>) -> bool
pub fn is_coincident(&self, other: &REdge<T>) -> 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 crossed_by_line(&self, line: &REdge<T>) -> ContainsResult
pub fn crossed_by_line(&self, line: &REdge<T>) -> ContainsResult
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: &REdge<T>) -> bool
pub fn lines_intersect(&self, other: &REdge<T>) -> bool
Test if lines defined by the edges intersect. If the lines are collinear they are also considered intersecting.
sourcepub fn edges_intersect(&self, other: &REdge<T>) -> ContainsResult
pub fn edges_intersect(&self, other: &REdge<T>) -> ContainsResult
Test if two edges intersect. If the edges coincide, they also intersect.
sourcepub fn oriented_distance_to_line(&self, point: Point<T>) -> T
pub fn oriented_distance_to_line(&self, point: Point<T>) -> T
Calculate the distance from the point to the line given by the edge.
Distance will be positive if the point lies on the right side of the edge and negative if the point is on the left side.
sourcepub fn distance_to_line(&self, point: Point<T>) -> T
pub fn distance_to_line(&self, point: Point<T>) -> T
Calculate the distance from the point to the line given by the edge.
sourcepub fn projection(&self, point: Point<T>) -> Point<T>
pub fn projection(&self, point: Point<T>) -> Point<T>
Find the perpendicular projection of a point onto the line of the edge.
sourcepub fn line_intersection(&self, other: &REdge<T>) -> RLineIntersection<T>
pub fn line_intersection(&self, other: &REdge<T>) -> RLineIntersection<T>
Compute the intersection of the two lines defined by the edges.
sourcepub fn edge_intersection(
&self,
other: &REdge<T>
) -> EdgeIntersection<T, T, REdge<T>>
pub fn edge_intersection(
&self,
other: &REdge<T>
) -> EdgeIntersection<T, T, REdge<T>>
Compute the intersection between two edges.
sourcepub fn rotate_ortho(&self, a: Angle) -> REdge<T>
pub fn rotate_ortho(&self, a: Angle) -> REdge<T>
Rotate the edge by a multiple of 90 degrees around (0, 0)
.
Trait Implementations
sourceimpl<T> BoundingBox<T> for REdge<T> where
T: CoordinateType,
impl<T> BoundingBox<T> for REdge<T> where
T: CoordinateType,
sourcefn bounding_box(&self) -> Rect<T>
fn bounding_box(&self) -> Rect<T>
Return the bounding box of this geometry.
sourceimpl<'de, T> Deserialize<'de> for REdge<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for REdge<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<REdge<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<REdge<T>, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> EdgeEndpoints<T> for REdge<T> where
T: Copy,
impl<T> EdgeEndpoints<T> for REdge<T> where
T: Copy,
sourceimpl<T> EdgeIntersect for REdge<T> where
T: CoordinateType,
impl<T> EdgeIntersect for REdge<T> where
T: CoordinateType,
type Coord = T
type Coord = T
Numeric type used for expressing the end-point coordinates of the edge.
type IntersectionCoord = T
type IntersectionCoord = T
Numeric type used for expressing an intersection-point of two edges.
Often this might be the same as Coord
. Read more
sourcefn edge_intersection(
&self,
other: &REdge<T>
) -> EdgeIntersection<<REdge<T> as EdgeIntersect>::Coord, <REdge<T> as EdgeIntersect>::IntersectionCoord, REdge<T>>
fn edge_intersection(
&self,
other: &REdge<T>
) -> EdgeIntersection<<REdge<T> as EdgeIntersect>::Coord, <REdge<T> as EdgeIntersect>::IntersectionCoord, REdge<T>>
Compute intersection of two edges.
sourceimpl<T> Into<Edge<T>> for &REdge<T> where
T: CoordinateType,
impl<T> Into<Edge<T>> for &REdge<T> where
T: CoordinateType,
sourceimpl<T> Into<Edge<T>> for REdge<T> where
T: CoordinateType,
impl<T> Into<Edge<T>> for REdge<T> where
T: CoordinateType,
sourceimpl<C> Segment<C> for REdge<<C as CoordinateBase>::Coord> where
C: CoordinateConcept,
impl<C> Segment<C> for REdge<<C as CoordinateBase>::Coord> where
C: CoordinateConcept,
type Point = Point<<C as CoordinateBase>::Coord>
type Point = Point<<C as CoordinateBase>::Coord>
Type used to represent the end points of the segment.
sourcefn get_point(
&self,
dir: Direction1D
) -> <REdge<<C as CoordinateBase>::Coord> as Segment<C>>::Point
fn get_point(
&self,
dir: Direction1D
) -> <REdge<<C as CoordinateBase>::Coord> as Segment<C>>::Point
Get the start (LOW) or end (HIGH) point of the segment.
sourceimpl<T> Serialize for REdge<T> where
T: Serialize,
impl<T> Serialize for REdge<T> where
T: Serialize,
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<T> TryBoundingBox<T> for REdge<T> where
T: CoordinateType,
impl<T> TryBoundingBox<T> for REdge<T> where
T: CoordinateType,
sourcefn try_bounding_box(&self) -> Option<Rect<T>>
fn try_bounding_box(&self) -> Option<Rect<T>>
Return the bounding box of this geometry if a bounding box is defined.
sourceimpl<T, Dst> TryCastCoord<T, Dst> for REdge<T> where
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
impl<T, Dst> TryCastCoord<T, Dst> for REdge<T> where
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
sourceimpl<T> TryFrom<&Edge<T>> for REdge<T> where
T: CoordinateType,
impl<T> TryFrom<&Edge<T>> for REdge<T> where
T: CoordinateType,
impl<T> Copy for REdge<T> where
T: Copy,
impl<T> Eq for REdge<T> where
T: Eq,
impl<T> StructuralEq for REdge<T>
impl<T> StructuralPartialEq for REdge<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for REdge<T> where
T: RefUnwindSafe,
impl<T> Send for REdge<T> where
T: Send,
impl<T> Sync for REdge<T> where
T: Sync,
impl<T> Unpin for REdge<T> where
T: Unpin,
impl<T> UnwindSafe for REdge<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more