[][src]Struct spade::primitives::SimpleEdge

pub struct SimpleEdge<V: PointN> {
    pub from: V,
    pub to: V,
}

An edge defined by it's two end points.

Fields

from: V

The edge's origin.

to: V

The edge's destination.

Methods

impl<V> SimpleEdge<V> where
    V: PointN
[src]

pub fn new(from: V, to: V) -> SimpleEdge<V>[src]

Creates a new edge from from to to.

pub fn is_projection_on_edge(&self, query_point: &V) -> bool[src]

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.

pub fn length2(&self) -> V::Scalar[src]

Returns the edge's squared length.

impl<V> SimpleEdge<V> where
    V: TwoDimensional
[src]

pub fn side_query<K: DelaunayKernel<V::Scalar>>(
    &self,
    q: &V
) -> EdgeSideInfo<V::Scalar>
[src]

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());

pub fn intersects_edge_non_collinear<K>(&self, other: &SimpleEdge<V>) -> bool where
    K: DelaunayKernel<V::Scalar>, 
[src]

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.

impl<V> SimpleEdge<V> where
    V: PointN,
    V::Scalar: SpadeFloat
[src]

pub fn nearest_point(&self, query_point: &V) -> V[src]

Yields the nearest point on this edge.

pub fn projection_distance2(&self, query_point: &V) -> V::Scalar[src]

Returns the squared distance of a given point to its projection onto the infinite line going through this edge's start and end point.

pub fn project_point(&self, query_point: &V) -> V::Scalar[src]

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

impl<V: PointN> SpatialObject for SimpleEdge<V> where
    V::Scalar: SpadeFloat
[src]

type Point = V

The object's point type.

impl<V: Eq + PointN> Eq for SimpleEdge<V>[src]

impl<V: Clone + PointN> Clone for SimpleEdge<V>[src]

impl<V: PartialOrd + PointN> PartialOrd<SimpleEdge<V>> for SimpleEdge<V>[src]

impl<V: Ord + PointN> Ord for SimpleEdge<V>[src]

impl<V: PartialEq + PointN> PartialEq<SimpleEdge<V>> for SimpleEdge<V>[src]

impl<V: Copy + PointN> Copy for SimpleEdge<V>[src]

impl<V: Hash + PointN> Hash for SimpleEdge<V>[src]

impl<V: Debug + PointN> Debug for SimpleEdge<V>[src]

Auto Trait Implementations

impl<V> Unpin for SimpleEdge<V> where
    V: Unpin

impl<V> Sync for SimpleEdge<V> where
    V: Sync

impl<V> Send for SimpleEdge<V> where
    V: Send

impl<V> UnwindSafe for SimpleEdge<V> where
    V: UnwindSafe

impl<V> RefUnwindSafe for SimpleEdge<V> where
    V: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Any + Debug
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>,