Struct rstar::primitives::Line [−][src]
pub struct Line<P> where
P: Point, {
pub from: P,
pub to: P,
}Expand description
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: PThe line’s start point
to: PThe line’s end point.
Implementations
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);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
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
Auto Trait Implementations
impl<P> RefUnwindSafe for Line<P> where
P: RefUnwindSafe,
impl<P> UnwindSafe for Line<P> where
P: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
