Struct spade::primitives::SimpleEdge
source · pub struct SimpleEdge<V: PointN> {
pub from: V,
pub to: V,
}
Expand description
An edge defined by it’s two end points.
Fields
from: V
The edge’s origin.
to: V
The edge’s destination.
Implementations
sourceimpl<V> SimpleEdge<V>where
V: PointN,
impl<V> SimpleEdge<V>where
V: PointN,
sourcepub fn new(from: V, to: V) -> SimpleEdge<V>
pub fn new(from: V, to: V) -> SimpleEdge<V>
Creates a new edge from from
to to
.
sourcepub fn is_projection_on_edge(&self, query_point: &V) -> bool
pub fn is_projection_on_edge(&self, query_point: &V) -> bool
Projects a point onto the infinite line going through the
edge’s start and end point and returns true
if the projected
points lies between from
and to
.
sourceimpl<V> SimpleEdge<V>where
V: TwoDimensional,
impl<V> SimpleEdge<V>where
V: TwoDimensional,
sourcepub fn side_query<K: DelaunayKernel<V::Scalar>>(
&self,
q: &V
) -> EdgeSideInfo<V::Scalar>
pub fn side_query<K: DelaunayKernel<V::Scalar>>(
&self,
q: &V
) -> EdgeSideInfo<V::Scalar>
Determines on which side of this edge a given point lies.
Example:
use nalgebra::Point2;
use spade::kernels::TrivialKernel;
use spade::primitives::SimpleEdge;
let e = SimpleEdge::new(Point2::new(0f32, 0.), Point2::new(1., 1.));
assert!(e.side_query::<TrivialKernel>(&Point2::new(1.0, 0.0)).is_on_right_side());
assert!(e.side_query::<TrivialKernel>(&Point2::new(0.0, 1.0)).is_on_left_side());
assert!(e.side_query::<TrivialKernel>(&Point2::new(0.5, 0.5)).is_on_line());
sourcepub fn intersects_edge_non_collinear<K>(&self, other: &SimpleEdge<V>) -> boolwhere
K: DelaunayKernel<V::Scalar>,
pub fn intersects_edge_non_collinear<K>(&self, other: &SimpleEdge<V>) -> boolwhere
K: DelaunayKernel<V::Scalar>,
Checks if this and another edge intersect.
The edges must not be collinear. Also, true
is returned if the edges
just touch each other.
Panics
Panics if both lines are collinear.
sourceimpl<V> SimpleEdge<V>where
V: PointN,
V::Scalar: SpadeFloat,
impl<V> SimpleEdge<V>where
V: PointN,
V::Scalar: SpadeFloat,
sourcepub fn nearest_point(&self, query_point: &V) -> V
pub fn nearest_point(&self, query_point: &V) -> V
Yields the nearest point on this edge.
sourcepub fn projection_distance2(&self, query_point: &V) -> V::Scalar
pub fn projection_distance2(&self, query_point: &V) -> V::Scalar
Returns the squared distance of a given point to its projection onto the infinite line going through this edge’s start and end point.
sourcepub fn project_point(&self, query_point: &V) -> V::Scalar
pub fn project_point(&self, query_point: &V) -> V::Scalar
Projects a point on this line and returns its relative position.
This method will return a value between 0. and 1. (linearly interpolated) if the projected
point lies between self.from
and self.to
, a value close to zero (due to rounding errors)
if the projected point is equal to self.from
and a value smaller than zero if the projected
point lies “before” self.from
. Analogously, a value close to 1. or greater than 1. is
returned if the projected point is equal to or lies behind self.to
.
Trait Implementations
sourceimpl<V: Clone + PointN> Clone for SimpleEdge<V>
impl<V: Clone + PointN> Clone for SimpleEdge<V>
sourcefn clone(&self) -> SimpleEdge<V>
fn clone(&self) -> SimpleEdge<V>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<V: Debug + PointN> Debug for SimpleEdge<V>
impl<V: Debug + PointN> Debug for SimpleEdge<V>
sourceimpl<V: Hash + PointN> Hash for SimpleEdge<V>
impl<V: Hash + PointN> Hash for SimpleEdge<V>
sourceimpl<V: Ord + PointN> Ord for SimpleEdge<V>
impl<V: Ord + PointN> Ord for SimpleEdge<V>
sourcefn cmp(&self, other: &SimpleEdge<V>) -> Ordering
fn cmp(&self, other: &SimpleEdge<V>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl<V: PartialEq + PointN> PartialEq<SimpleEdge<V>> for SimpleEdge<V>
impl<V: PartialEq + PointN> PartialEq<SimpleEdge<V>> for SimpleEdge<V>
sourcefn eq(&self, other: &SimpleEdge<V>) -> bool
fn eq(&self, other: &SimpleEdge<V>) -> bool
sourceimpl<V: PartialOrd + PointN> PartialOrd<SimpleEdge<V>> for SimpleEdge<V>
impl<V: PartialOrd + PointN> PartialOrd<SimpleEdge<V>> for SimpleEdge<V>
sourcefn partial_cmp(&self, other: &SimpleEdge<V>) -> Option<Ordering>
fn partial_cmp(&self, other: &SimpleEdge<V>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl<V: PointN> SpatialObject for SimpleEdge<V>where
V::Scalar: SpadeFloat,
impl<V: PointN> SpatialObject for SimpleEdge<V>where
V::Scalar: SpadeFloat,
type Point = V
type Point = V
sourcefn mbr(&self) -> BoundingRect<V>
fn mbr(&self) -> BoundingRect<V>
impl<V: Copy + PointN> Copy for SimpleEdge<V>
impl<V: Eq + PointN> Eq for SimpleEdge<V>
impl<V: PointN> StructuralEq for SimpleEdge<V>
impl<V: PointN> StructuralPartialEq for SimpleEdge<V>
Auto Trait Implementations
impl<V> RefUnwindSafe for SimpleEdge<V>where
V: RefUnwindSafe,
impl<V> Send for SimpleEdge<V>where
V: Send,
impl<V> Sync for SimpleEdge<V>where
V: Sync,
impl<V> Unpin for SimpleEdge<V>where
V: Unpin,
impl<V> UnwindSafe for SimpleEdge<V>where
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.