Struct geo_types::Line[][src]

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

Methods

impl<T> Line<T> where
    T: CoordinateType
[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. });

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

Equivalent to:

line.end.x - line.start.x

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

Equivalent to:

line.end.y - line.start.y

Calculate the slope (Δy/Δx).

Equivalent to:

line.dy() / line.dx()

Note that:

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

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

Trait Implementations

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

Formats the value using the given formatter. Read more

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

Performs the conversion.

Auto Trait Implementations

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

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