Struct libreda_pnr::db::REdge [−]
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
impl<T> REdge<T> where
T: CoordinateType,
T: CoordinateType,
pub fn new<C>(start: C, end: C) -> REdge<T> where
C: Into<Point<T>>,
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.
pub fn new_raw(
start: T,
end: T,
offset: T,
orientation: REdgeOrientation
) -> REdge<T>
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.
pub fn try_from_points<C>(start: C, end: C) -> Option<REdge<T>> where
C: Into<Point<T>>,
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.
pub fn start(&self) -> Point<T>
Get the start point of the edge.
pub fn end(&self) -> Point<T>
Get the end point of the edge.
pub fn reversed(&self) -> REdge<T>
Return the same edge but with the two points swapped.
pub fn is_degenerate(&self) -> bool
Check if edge is degenerate. An edge is degenerate if start point and end point are equal.
pub fn is_ortho(&self) -> bool
Test if this edge is either horizontal or vertical.
pub fn is_horizontal(&self) -> bool
Test if this edge is horizontal.
pub fn is_vertical(&self) -> bool
Test if this edge is vertical.
pub fn vector(&self) -> Vector<T>
Returns the vector from self.start()
to self.end()
.
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.
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.
pub fn contains_point(&self, point: Point<T>) -> ContainsResult
Test if point lies on the edge. Includes start and end points of edge.
pub fn line_contains_point(&self, point: Point<T>) -> bool
Test if point lies on the line defined by the edge.
pub fn is_parallel(&self, other: &REdge<T>) -> bool
Test if two edges are parallel.
pub fn is_collinear(&self, other: &REdge<T>) -> bool where
T: CoordinateType,
T: CoordinateType,
Test if two edges are collinear, i.e. are on the same line.
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).
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.
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.
pub fn edges_intersect(&self, other: &REdge<T>) -> ContainsResult
Test if two edges intersect. If the edges coincide, they also intersect.
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.
pub fn distance_to_line(&self, point: Point<T>) -> T
Calculate the distance from the point to the line given by the edge.
pub fn projection(&self, point: Point<T>) -> Point<T>
Find the perpendicular projection of a point onto the line of the edge.
pub fn line_intersection(&self, other: &REdge<T>) -> RLineIntersection<T>
Compute the intersection of the two lines defined by the edges.
pub fn edge_intersection(&self, other: &REdge<T>) -> REdgeIntersection<T>
Compute the intersection between two edges.
pub fn rotate_ortho(&self, a: Angle) -> REdge<T>
Rotate the edge by a multiple of 90 degrees around (0, 0)
.
Trait Implementations
impl<T> BoundingBox<T> for REdge<T> where
T: CoordinateType,
T: CoordinateType,
pub fn bounding_box(&self) -> Rect<T>
impl<T> Clone for REdge<T> where
T: CoordinateType + Clone,
T: CoordinateType + Clone,
pub fn clone(&self) -> REdge<T>
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Copy for REdge<T> where
T: CoordinateType + Copy,
T: CoordinateType + Copy,
impl<T> Debug for REdge<T> where
T: CoordinateType + Debug,
T: CoordinateType + Debug,
impl<T> Eq for REdge<T> where
T: CoordinateType + Eq,
T: CoordinateType + Eq,
impl<T> Hash for REdge<T> where
T: CoordinateType + Hash,
T: CoordinateType + Hash,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T> Into<(Point<T>, Point<T>)> for REdge<T> where
T: CoordinateType,
T: CoordinateType,
impl<'_, T> Into<(Point<T>, Point<T>)> for &'_ REdge<T> where
T: CoordinateType,
T: CoordinateType,
impl<'_, T> Into<Edge<T>> for &'_ REdge<T> where
T: CoordinateType,
T: CoordinateType,
impl<T> PartialEq<REdge<T>> for REdge<T> where
T: CoordinateType + PartialEq<T>,
T: CoordinateType + PartialEq<T>,
impl<T> StructuralEq for REdge<T> where
T: CoordinateType,
T: CoordinateType,
impl<T> StructuralPartialEq for REdge<T> where
T: CoordinateType,
T: CoordinateType,
impl<T, Dst> TryCastCoord<T, Dst> for REdge<T> where
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
T: CoordinateType + NumCast,
Dst: CoordinateType + NumCast,
type Output = REdge<Dst>
Output type of the cast. This is likely the same geometrical type just with other coordinate types. Read more
pub fn try_cast(&self) -> Option<<REdge<T> as TryCastCoord<T, Dst>>::Output>
pub fn cast(&self) -> Self::Output
impl<'_, T> TryFrom<&'_ Edge<T>> for REdge<T> where
T: CoordinateType,
T: CoordinateType,
Auto Trait Implementations
impl<T> RefUnwindSafe for REdge<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for REdge<T> where
T: Send,
T: Send,
impl<T> Sync for REdge<T> where
T: Sync,
T: Sync,
impl<T> Unpin for REdge<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for REdge<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> TextType for T where
T: Clone + Eq + Debug + Hash,
T: Clone + Eq + Debug + Hash,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,