Type Alias spade::handles::DirectedEdgeHandle

source ·
pub type DirectedEdgeHandle<'a, V, DE, UE, F> = DynamicHandleImpl<'a, V, DE, UE, F, DirectedEdgeTag, InnerTag>;
Expand description

Handle to a directed edge of a triangulation.

Use this handle to examine the edge’s surroundings, e.g. its origin and destination vertices or the adjacent face.

§Retrieving neighboring edges:

Use Self::next, Self::prev, Self::rev to access any adjacent edge:

e e.rev() e.next() e.prev()

§Retrieving adjacent faces and vertices

Use Self::face, Self::from and Self::to to access the adjacent face and vertices:

e e.face() e.from() e.to()

See also the handles module.

Aliased Type§

struct DirectedEdgeHandle<'a, V, DE, UE, F> { /* private fields */ }

Implementations§

source§

impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F>

source

pub fn vertices(&self) -> [VertexHandle<'a, V, DE, UE, F>; 2]

Returns the edge’s two vertices.

The first vertex is self.from(), the second vertex is self.to().

source

pub fn from(&self) -> VertexHandle<'a, V, DE, UE, F>

Returns the edge’s origin vertex.

source

pub fn to(&self) -> VertexHandle<'a, V, DE, UE, F>

Returns the edge’s destination vertex.

source

pub fn rev(&self) -> Self

Returns this edge in reversed direction.

source

pub fn opposite_vertex(&self) -> Option<VertexHandle<'a, V, DE, UE, F>>

Returns the vertex which lies opposite of this edge.

This is equal to calling self.prev().from() or self.next().to(). Returns None if this edge is part of the convex hull.

source

pub fn next(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F>

Returns the oriented next edge.

The oriented next edge shares the same face as this edge. When traversing the face’s edges in oriented order, this edge is the predecessor of the oriented next edge. “Oriented” means counterclockwise for right handed coordinate systems.

source

pub fn prev(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F>

Returns the oriented previous edge.

The oriented previous edge shares the same face as this edge. When traversing the face’s edges in oriented order, this edge is the successor of the oriented previous edge. “Oriented” means counterclockwise for right handed coordinate systems.

source

pub fn face(&self) -> FaceHandle<'a, PossiblyOuterTag, V, DE, UE, F>

Returns the face located to the left of this edge.

source

pub fn cw(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F>

Returns the next edge in clockwise direction.

Note that this assumes that you use a right handed coordinate system, otherwise the sense of orientation is inverted.

source

pub fn ccw(&self) -> DirectedEdgeHandle<'a, V, DE, UE, F>

Returns the next edge in counter clockwise direction.

Note that this assumes that you use a right handed coordinate system, otherwise the sense of orientation is inverted.

source

pub fn data(&self) -> &'a DE

Returns a reference to the data associated with this directed edge.

Use Triangulation::directed_edge_data_mut to modify the edge data.

source

pub fn as_undirected(self) -> UndirectedEdgeHandle<'a, V, DE, UE, F>

Converts this directed edge handle into an undirected edge handle.

See also the handles module.

source

pub fn is_outer_edge(&self) -> bool

Returns true if this edge is adjacent to the outer face.

source

pub fn is_part_of_convex_hull(&self) -> bool

Returns true if either this edge or its reversed edge is adjacent to the outer face.

source

pub fn as_voronoi_edge(&self) -> DirectedVoronoiEdge<'a, V, DE, UE, F>

Converts this edge into its dual voronoi edge.

See also as_delaunay_edge.

source§

impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F>
where V: HasPosition,

source

pub fn positions(&self) -> [Point2<<V as HasPosition>::Scalar>; 2]

Returns the start and end position of this edge.

The first returned position is self.from().position(), the second is self.to().position().

source

pub fn opposite_position(&self) -> Option<Point2<V::Scalar>>

Returns the position of the vertex opposite of this edge.

See also opposite_vertex(). Returns None if this edge is an outer edge.

source

pub fn length_2(&self) -> V::Scalar

Returns the squared length of this edge.

source

pub fn side_query(&self, query_point: Point2<V::Scalar>) -> LineSideInfo

Identifies on which side of this edge a point lies.

source

pub fn project_point( &self, query_point: Point2<V::Scalar> ) -> PointProjection<V::Scalar>

Indicates the position of a point being projected onto this edge.

A point’s projection can either come before, on or behind this edge. Note that this method may return inaccurate results due to rounding issues.

before on edge behind

An image displaying differently colored areas which would result in different point projections

§Example
use spade::{Point2, Triangulation, DelaunayTriangulation};

let from = Point2::new(0.0, 0.0);
let to = Point2::new(2.0, 0.0);

let mut triangulation: DelaunayTriangulation<_> = Default::default();
let v0 = triangulation.insert(from)?;
let v1 = triangulation.insert(to)?;
// This edge goes from "from" to "to"
let edge = triangulation.get_edge_from_neighbors(v0, v1).unwrap();

// These vertices are all projected before the edge
assert!(edge.project_point(Point2::new(-0.2, 0.0)).is_before_edge());
assert!(edge.project_point(Point2::new(-1002.0, -12.0)).is_before_edge());

// These vertices are all projected onto the edge
assert!(edge.project_point(Point2::new(1.0, 5.0)).is_on_edge());
assert!(edge.project_point(Point2::new(0.5, -2.0)).is_on_edge());
assert!(edge.project_point(Point2::new(1.0, 0.0)).is_on_edge());

// These vertices are all projected behind the edge
assert!(edge.project_point(Point2::new(4.000001, 0.0)).is_behind_edge());
assert!(edge.project_point(Point2::new(5.0, -12.0)).is_behind_edge());
source§

impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, CdtEdge<UE>, F>

source

pub fn is_constraint_edge(self) -> bool

Returns true if this edge is a constraint edge.

source§

impl<'a, V, DE, UE, F> DirectedEdgeHandle<'a, V, DE, UE, F>
where V: HasPosition, V::Scalar: Float,

source

pub fn distance_2(&self, query_point: Point2<V::Scalar>) -> V::Scalar

Returns the squared distance of a point to this edge.

source

pub fn nearest_point(&self, query_point: Point2<V::Scalar>) -> Point2<V::Scalar>

Yields the nearest point on this edge.

source

pub fn center(&self) -> Point2<V::Scalar>

Returns the center of this edge

Trait Implementations§

source§

impl<'a, V, DE, UE, F> AsRef<DE> for DirectedEdgeHandle<'a, V, DE, UE, F>

source§

fn as_ref(&self) -> &DE

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a, V, DE, UE, F> Debug for DirectedEdgeHandle<'a, V, DE, UE, F>

source§

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

Formats the value using the given formatter. Read more