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
Coordinate
s. 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);
type Epsilon = T
type Epsilon = T
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
.
impl<T> RelativeEq<Triangle<T>> for Triangle<T> where
T: AbsDiffEq<Epsilon = T> + CoordNum + RelativeEq,
impl<T> RelativeEq<Triangle<T>> for Triangle<T> where
T: AbsDiffEq<Epsilon = T> + CoordNum + RelativeEq,
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.
Auto Trait Implementations
impl<T> RefUnwindSafe for Triangle<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Triangle<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more