Struct libreda_db::layout::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§

source§

impl<T> REdge<T>

source

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

impl<T> REdge<T>
where T: Copy,

source

pub fn start(&self) -> Point<T>

Get the start point of the edge.

source

pub fn end(&self) -> Point<T>

Get the end point of the edge.

source

pub fn reversed(&self) -> REdge<T>

Return the same edge but with the two points swapped.

source§

impl<T> REdge<T>
where T: PartialEq,

source

pub fn is_degenerate(&self) -> bool

Check if edge is degenerate. An edge is degenerate if start point and end point are equal.

source

pub fn is_ortho(&self) -> bool

Test if this edge is either horizontal or vertical.

source

pub fn is_horizontal(&self) -> bool

Test if this edge is horizontal.

source

pub fn is_vertical(&self) -> bool

Test if this edge is vertical.

source§

impl<T> REdge<T>
where T: PartialOrd + Sub<Output = T> + Copy,

source

pub fn length(&self) -> T

Get the length of the edge.

source§

impl<T> REdge<T>
where T: CoordinateType,

source

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.

source

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.

source

pub fn vector(&self) -> Vector<T>

Returns the vector from self.start() to self.end().

source

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.

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 manhattan_distance_to_point(self, p: Point<T>) -> T

Compute the manhattan distance of a point to the edge.

source

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

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: &REdge<T>) -> bool

Test if two edges are parallel.

source

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.

source

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

source

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.

source

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.

source

pub fn edges_intersect(&self, other: &REdge<T>) -> ContainsResult

Test if two edges intersect. If the edges coincide, they also intersect.

source

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.

source

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

Calculate the distance from the point to the line given by the edge.

source

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

Find the perpendicular projection of a point onto the line of the edge.

source

pub fn line_intersection(&self, other: &REdge<T>) -> RLineIntersection<T>

Compute the intersection of the two lines defined by the edges.

source

pub fn edge_intersection( &self, other: &REdge<T>, ) -> EdgeIntersection<T, T, REdge<T>>

Compute the intersection between two edges.

source

pub fn rotate_ortho(&self, a: Angle) -> REdge<T>

Rotate the edge by a multiple of 90 degrees around (0, 0).

Trait Implementations§

source§

impl<T> BoundingBox<T> for REdge<T>
where T: CoordinateType,

source§

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

Return the bounding box of this geometry.
source§

impl<T> Clone for REdge<T>
where T: Clone,

source§

fn clone(&self) -> REdge<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> Debug for REdge<T>
where T: Debug,

source§

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

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

impl<'de, T> Deserialize<'de> for REdge<T>
where T: Deserialize<'de>,

source§

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

impl<T> EdgeEndpoints<T> for REdge<T>
where T: Copy,

source§

fn start(&self) -> Point<T>

Get the start point of the edge.
source§

fn end(&self) -> Point<T>

Get the end point of the edge.
source§

impl<T> EdgeIntersect for REdge<T>
where T: CoordinateType,

§

type Coord = T

Numeric type used for expressing the end-point coordinates of the edge.
§

type IntersectionCoord = T

Numeric type used for expressing an intersection-point of two edges. Often this might be the same as Coord.
source§

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

impl<T> From<&REdge<T>> for Edge<T>
where T: Copy,

source§

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

Converts to this type from the input type.
source§

impl<T> From<REdge<T>> for Edge<T>
where T: Copy,

source§

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

Converts to this type from the input type.
source§

impl<T> Hash for REdge<T>
where T: Hash,

source§

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

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> PartialEq for REdge<T>
where T: PartialEq,

source§

fn eq(&self, other: &REdge<T>) -> 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<C> Segment<C> for REdge<<C as CoordinateBase>::Coord>

§

type Point = Point<<C as CoordinateBase>::Coord>

Type used to represent the end points of the segment.
source§

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

fn start(&self) -> Self::Point

Shortcut to get the ‘low’ end of the segment.
source§

fn end(&self) -> Self::Point

Shortcut to get the ‘high’ end of the segment.
source§

impl<T> Serialize for REdge<T>
where T: Serialize,

source§

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

impl<T> TryBoundingBox<T> for REdge<T>
where T: CoordinateType,

source§

fn try_bounding_box(&self) -> Option<Rect<T>>

Return the bounding box of this geometry if a bounding box is defined.
source§

impl<T, Dst> TryCastCoord<T, Dst> for REdge<T>

§

type Output = REdge<Dst>

Output type of the cast. This is likely the same geometrical type just with other coordinate types.
source§

fn try_cast(&self) -> Option<<REdge<T> as TryCastCoord<T, Dst>>::Output>

Try to cast to target data type. Read more
source§

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

Cast to target data type. Read more
source§

impl<T> TryFrom<&Edge<T>> for REdge<T>
where T: CoordinateType,

source§

fn try_from( value: &Edge<T>, ) -> Result<REdge<T>, <REdge<T> as TryFrom<&Edge<T>>>::Error>

Try to convert an edge into a rectilinear edge. Returns none if the edge is not rectilinear.

§

type Error = ()

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

impl<T> Copy for REdge<T>
where T: Copy,

source§

impl<T> Eq for REdge<T>
where T: Eq,

source§

impl<T> StructuralPartialEq for REdge<T>

Auto Trait Implementations§

§

impl<T> Freeze for REdge<T>
where T: Freeze,

§

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§

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> 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<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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> IdType for T
where T: Debug + Clone + Eq + Hash + 'static,

source§

impl<T> IdTypeMT for T
where T: IdType + Sync + Send,

source§

impl<T> TextType for T
where T: Eq + Hash + Clone + Debug,