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

Creates a new edge from from to to.

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.

Returns the edge’s squared length.

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

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.

Yields the nearest point on this edge.

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

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The object’s point type.
Returns the object’s minimal bounding rectangle. Read more
Returns the squared euclidean distance from the object’s contour. Returns a value samller than zero if the point is contained within the object. Read more
Returns true if a given point is contained in this object.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
Tests if Self the same as the type T Read more
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.