logo

Struct geo_types::Triangle[][src]

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

Create a Polygon from the Triangle.

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

let triangle = Triangle(
    Coordinate { x: 0., y: 0. },
    Coordinate { x: 10., y: 20. },
    Coordinate { 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

Equality assertion with an absolute limit.

Examples
use geo_types::{point, Triangle};

let a = Triangle((0.0, 0.0).into(), (10.0, 10.0).into(), (0.0, 5.0).into());
let b = Triangle((0.0, 0.0).into(), (10.01, 10.0).into(), (0.0, 5.0).into());

approx::abs_diff_eq!(a, b, epsilon=0.1);
approx::abs_diff_ne!(a, b, epsilon=0.001);

Used for specifying relative comparisons.

The default tolerance to use when testing values that are close together. Read more

The inverse of AbsDiffEq::abs_diff_eq.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

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 !=.

Equality assertion within a relative limit.

Examples
use geo_types::{point, Triangle};

let a = Triangle((0.0, 0.0).into(), (10.0, 10.0).into(), (0.0, 5.0).into());
let b = Triangle((0.0, 0.0).into(), (10.01, 10.0).into(), (0.0, 5.0).into());

approx::assert_relative_eq!(a, b, max_relative=0.1);
approx::assert_relative_ne!(a, b, max_relative=0.0001);

The default relative tolerance for testing values that are far-apart. Read more

The inverse of RelativeEq::relative_eq.

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

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)

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.