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: P

The line’s start point

to: P

The line’s end point.

Implementations

Creates a new line between two points.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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 !=.

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

Returns the squared euclidean distance of an object to a point.

Returns true if a point is contained within this object. Read more

Returns the squared distance to this object or None if the distance is larger than a given maximum value. Read more

The object’s envelope type. Usually, AABB will be the right choice. This type also defines the objects dimensionality. Read more

Returns the object’s envelope. Read more

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

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.