[][src]Struct geo::Line

pub struct Line<T> where
    T: CoordinateType
{ pub start: Coordinate<T>, pub end: Coordinate<T>, }

A line segment made up of exactly two Points.

Fields

start: Coordinate<T>end: Coordinate<T>

Methods

impl<T> Line<T> where
    T: CoordinateType
[src]

pub fn new<C>(start: C, end: C) -> Line<T> where
    C: Into<Coordinate<T>>, 
[src]

Creates a new line segment.

Examples

use geo_types::{Coordinate, Line};

let line = Line::new(
    Coordinate { x: 0., y: 0. },
    Coordinate { x: 1., y: 2. },
);

assert_eq!(line.start, Coordinate { x: 0., y: 0. });
assert_eq!(line.end, Coordinate { x: 1., y: 2. });

pub fn dx(&self) -> T[src]

Calculate the difference in ‘x’ components (Δx).

Equivalent to:

line.end.x - line.start.x

pub fn dy(&self) -> T[src]

Calculate the difference in ‘y’ components (Δy).

Equivalent to:

line.end.y - line.start.y

pub fn slope(&self) -> T[src]

Calculate the slope (Δy/Δx).

Equivalent to:

line.dy() / line.dx()

Note that:

Line::new(a, b).slope() ==
    Line::new(b, a).slope()

pub fn determinant(&self) -> T[src]

Calculate the determinant of the line.

Equivalent to:

line.start.x * line.end.y -
    line.start.y * line.end.x

Note that:

Line::new(a, b).determinant() ==
    -Line::new(b, a).determinant()

pub fn start_point(&self) -> Point<T>[src]

pub fn end_point(&self) -> Point<T>[src]

pub fn points(&self) -> (Point<T>, Point<T>)[src]

Trait Implementations

impl<T> Copy for Line<T> where
    T: Copy + CoordinateType
[src]

impl<T> Clone for Line<T> where
    T: Clone + CoordinateType
[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T> RTreeObject for Line<T> where
    T: Float + RTreeNum
[src]

type Envelope = AABB<Point<T>>

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

impl<T> From<[(T, T); 2]> for Line<T> where
    T: CoordinateType
[src]

impl<T> From<Line<T>> for Geometry<T> where
    T: CoordinateType
[src]

impl<T> Debug for Line<T> where
    T: Debug + CoordinateType
[src]

impl<T> PartialEq<Line<T>> for Line<T> where
    T: PartialEq<T> + CoordinateType
[src]

impl<T> PointDistance for Line<T> where
    T: Float + RTreeNum
[src]

default fn contains_point(
    &self,
    point: &<Self::Envelope as Envelope>::Point
) -> bool
[src]

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

impl<T> Area<T> for Line<T> where
    T: CoordinateType
[src]

impl<T> BoundingRect<T> for Line<T> where
    T: CoordinateType
[src]

type Output = Rect<T>

impl<T> Centroid<T> for Line<T> where
    T: Float
[src]

type Output = Point<T>

impl<F: Float> ClosestPoint<F, Point<F>> for Line<F>[src]

impl<T> Contains<Point<T>> for Line<T> where
    T: Float
[src]

impl<T> Contains<Line<T>> for Line<T> where
    T: Float
[src]

impl<T> Contains<LineString<T>> for Line<T> where
    T: Float
[src]

impl<T> Contains<Line<T>> for LineString<T> where
    T: Float
[src]

impl<T> Contains<Line<T>> for Polygon<T> where
    T: Float
[src]

impl<T> EuclideanDistance<T, Point<T>> for Line<T> where
    T: Float
[src]

fn euclidean_distance(&self, point: &Point<T>) -> T[src]

Minimum distance from a Line to a Point

impl<T> EuclideanDistance<T, Line<T>> for Point<T> where
    T: Float
[src]

fn euclidean_distance(&self, line: &Line<T>) -> T[src]

Minimum distance from a Line to a Point

impl<T> EuclideanDistance<T, Line<T>> for LineString<T> where
    T: Float + FloatConst + Signed + RTreeNum
[src]

LineString to Line

impl<T> EuclideanDistance<T, LineString<T>> for Line<T> where
    T: Float + FloatConst + Signed + RTreeNum
[src]

Line to LineString

impl<T> EuclideanDistance<T, MultiPolygon<T>> for Line<T> where
    T: Float + FloatConst + Signed + RTreeNum
[src]

Line to MultiPolygon distance

impl<T> EuclideanDistance<T, Line<T>> for MultiPolygon<T> where
    T: Float + FloatConst + Signed + RTreeNum
[src]

MultiPolygon to Line distance

impl<T> EuclideanDistance<T, Line<T>> for Line<T> where
    T: Float + FloatConst + Signed + RTreeNum
[src]

Line to Line distance

impl<T> EuclideanDistance<T, Polygon<T>> for Line<T> where
    T: Float + Signed + RTreeNum + FloatConst
[src]

impl<T> EuclideanDistance<T, Line<T>> for Polygon<T> where
    T: Float + FloatConst + Signed + RTreeNum
[src]

impl<T> EuclideanLength<T, Line<T>> for Line<T> where
    T: Float
[src]

impl<T> HaversineLength<T, Line<T>> for Line<T> where
    T: Float + FromPrimitive
[src]

impl<T> Intersects<Point<T>> for Line<T> where
    T: Float
[src]

impl<T> Intersects<Line<T>> for Point<T> where
    T: Float
[src]

impl<T> Intersects<Line<T>> for Line<T> where
    T: Float
[src]

impl<T> Intersects<LineString<T>> for Line<T> where
    T: Float
[src]

impl<T> Intersects<Line<T>> for LineString<T> where
    T: Float
[src]

impl<T> Intersects<Polygon<T>> for Line<T> where
    T: Float
[src]

impl<T> Intersects<Line<T>> for Polygon<T> where
    T: Float
[src]

impl<T: CoordinateType, NT: CoordinateType> MapCoords<T, NT> for Line<T>[src]

type Output = Line<NT>

impl<T: CoordinateType, NT: CoordinateType> TryMapCoords<T, NT> for Line<T>[src]

type Output = Line<NT>

impl<T: CoordinateType> MapCoordsInplace<T> for Line<T>[src]

impl<T> Rotate<T> for Line<T> where
    T: Float
[src]

impl<T> VincentyLength<T, Line<T>> for Line<T> where
    T: Float + FromPrimitive
[src]

fn vincenty_length(&self) -> Result<T, FailedToConvergeError>[src]

The units of the returned value is meters.

Auto Trait Implementations

impl<T> Send for Line<T> where
    T: Send

impl<T> Sync for Line<T> where
    T: Sync

Blanket Implementations

impl<T, G> RotatePoint for G where
    G: MapCoords<T, T, Output = G>,
    T: Float
[src]

impl<T, G> Translate for G where
    G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
    T: CoordinateType
[src]

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

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

type Owned = T

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

impl<T, U> TryInto 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> Any for T where
    T: 'static + ?Sized
[src]

impl<P> RTreeObject for P where
    P: Point
[src]

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

impl<P> PointDistance for P where
    P: Point
[src]