logo
pub struct Triangle<T: CoordNum>(pub Coordinate<T>, pub Coordinate<T>, pub Coordinate<T>);
Expand description

A bounded 2D area whose three vertices are defined by Coordinates. The semantics and validity are that of the equivalent Polygon; in addition, the three vertices must not be collinear and they must be distinct.

Tuple Fields

0: Coordinate<T>1: Coordinate<T>2: Coordinate<T>

Implementations

Instantiate Self from the raw content value

Create a Polygon from the Triangle.

Examples
use geo_types::{coord, Triangle, polygon};

let triangle = Triangle::new(
    coord! { x: 0., y: 0. },
    coord! { x: 10., y: 20. },
    coord! { x: 20., y: -10. },
);

assert_eq!(
    triangle.to_polygon(),
    polygon![
        (x: 0., y: 0.),
        (x: 10., y: 20.),
        (x: 20., y: -10.),
        (x: 0., y: 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

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

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

This method tests for !=.

Convert a Geometry enum into its inner type.

Fails if the enum case does not match the type you are trying to convert it to.

The type returned in the event of a conversion error.

Performs the conversion.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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)

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.