[−][src]Struct rstar::primitives::Line
A line defined by a start and and end point.
This struct can be inserted directly into an r-tree.
Type parameters
P
: The line's Point type.
Example
use rstar::primitives::Line; use rstar::{RTree, RTreeObject}; let line_1 = Line::new([0.0, 0.0], [1.0, 1.0]); let line_2 = Line::new([0.0, 0.0], [-1.0, 1.0]); let tree = RTree::bulk_load(vec![line_1, line_2]); assert!(tree.contains(&line_1));
Fields
from: P
The line's start point
to: P
The line's end point.
Implementations
impl<P> Line<P> where
P: Point,
[src]
P: Point,
impl<P> Line<P> where
P: Point,
[src]
P: Point,
pub fn length_2(&self) -> P::Scalar
[src]
Returns the squared length of this line.
Example
use rstar::primitives::Line; let line = Line::new([3, 3], [7, 6]); assert_eq!(line.length_2(), 25);
pub fn nearest_point(&self, query_point: &P) -> P
[src]
Returns the nearest point on this line relative to a given point.
Example
use rstar::primitives::Line; let line = Line::new([0.0, 0.0], [1., 1.]); assert_eq!(line.nearest_point(&[0.0, 0.0]), [0.0, 0.0]); assert_eq!(line.nearest_point(&[1.0, 0.0]), [0.5, 0.5]); assert_eq!(line.nearest_point(&[10., 12.]), [1.0, 1.0]);
Trait Implementations
impl<P: Clone> Clone for Line<P> where
P: Point,
[src]
P: Point,
impl<P: Copy> Copy for Line<P> where
P: Point,
[src]
P: Point,
impl<P: Debug> Debug for Line<P> where
P: Point,
[src]
P: Point,
impl<P: Eq> Eq for Line<P> where
P: Point,
[src]
P: Point,
impl<P: Ord> Ord for Line<P> where
P: Point,
[src]
P: Point,
fn cmp(&self, other: &Line<P>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<P: PartialEq> PartialEq<Line<P>> for Line<P> where
P: Point,
[src]
P: Point,
impl<P: PartialOrd> PartialOrd<Line<P>> for Line<P> where
P: Point,
[src]
P: Point,
fn partial_cmp(&self, other: &Line<P>) -> Option<Ordering>
[src]
fn lt(&self, other: &Line<P>) -> bool
[src]
fn le(&self, other: &Line<P>) -> bool
[src]
fn gt(&self, other: &Line<P>) -> bool
[src]
fn ge(&self, other: &Line<P>) -> bool
[src]
impl<P> PointDistance for Line<P> where
P: Point,
[src]
P: Point,
fn distance_2(
&self,
point: &<Self::Envelope as Envelope>::Point
) -> <<Self::Envelope as Envelope>::Point as Point>::Scalar
[src]
&self,
point: &<Self::Envelope as Envelope>::Point
) -> <<Self::Envelope as Envelope>::Point as Point>::Scalar
fn contains_point(&self, point: &<Self::Envelope as Envelope>::Point) -> bool
[src]
fn distance_2_if_less_or_equal(
&self,
point: &<Self::Envelope as Envelope>::Point,
max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar
) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>
[src]
&self,
point: &<Self::Envelope as Envelope>::Point,
max_distance_2: <<Self::Envelope as Envelope>::Point as Point>::Scalar
) -> Option<<<Self::Envelope as Envelope>::Point as Point>::Scalar>
impl<P> RTreeObject for Line<P> where
P: Point,
[src]
P: Point,
type Envelope = AABB<P>
The object's envelope type. Usually, AABB will be the right choice. This type also defines the objects dimensionality. Read more
fn envelope(&self) -> Self::Envelope
[src]
impl<P> StructuralEq for Line<P> where
P: Point,
[src]
P: Point,
impl<P> StructuralPartialEq for Line<P> where
P: Point,
[src]
P: Point,
Auto Trait Implementations
impl<P> RefUnwindSafe for Line<P> where
P: RefUnwindSafe,
P: RefUnwindSafe,
impl<P> Send for Line<P> where
P: Send,
P: Send,
impl<P> Sync for Line<P> where
P: Sync,
P: Sync,
impl<P> Unpin for Line<P> where
P: Unpin,
P: Unpin,
impl<P> UnwindSafe for Line<P> where
P: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,