# [−][src]Struct geo_types::Line

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

A line segment made up of exactly two `Coordinate`s.

# Semantics

The interior and boundary are defined as with a `LineString` with the two end points.

## Fields

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

## Implementations

### `impl<T> Line<T> where    T: CoordNum, `[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 delta(&self) -> Coordinate<T>`[src]

Calculate the difference in coordinates (Δx, Δy).

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

## Trait Implementations

### `impl<T: CoordNum> TryFrom<Geometry<T>> for Line<T>`[src]

#### `type Error = FailedToConvertError`

The type returned in the event of a conversion error.

## Blanket Implementations

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

#### `type Owned = T`

The resulting type after obtaining ownership.

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

#### `type Error = Infallible`

The type returned in the event of a conversion error.

### `impl<T, U> TryInto<U> for T where    U: TryFrom<T>, `[src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.