Struct geo::Triangle [−][src]
pub struct Triangle<T>(pub Coordinate<T>, pub Coordinate<T>, pub Coordinate<T>)
where
T: CoordNum;
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
.
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
Return the number of coordinates in the Triangle
.
type Iter = Chain<Chain<Once<Coordinate<T>>, Once<Coordinate<T>>>, Once<Coordinate<T>>>
type ExteriorIter = Self::Iter
type Scalar = T
Iterate over all exterior and (if any) interior coordinates of a geometry. Read more
Iterate over all exterior coordinates of a geometry. Read more
Returns the distance between two geometries Read more
Some geometries, like a MultiPoint
, can have zero coordinates - we call these empty
. Read more
The dimensions of some geometries are fixed, e.g. a Point always has 0 dimensions. However
for others, the dimensionality depends on the specific geometry instance - for example
typical Rect
s are 2-dimensional, but it’s possible to create degenerate Rect
s which
have either 1 or 0 dimensions. Read more
The dimensions of the Geometry
’s boundary, as used by OGC-SFA. Read more
impl<T> Intersects<Triangle<T>> for Coordinate<T> where
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Coordinate<T> where
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Line<T> where
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Line<T> where
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Rect<T> where
Triangle<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Rect<T> where
Triangle<T>: Intersects<Rect<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Polygon<T> where
Triangle<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> Intersects<Triangle<T>> for Polygon<T> where
Triangle<T>: Intersects<Polygon<T>>,
T: CoordNum,
impl<T> RelativeEq<Triangle<T>> for Triangle<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
impl<T> RelativeEq<Triangle<T>> for Triangle<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
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
Rotate a Geometry around an arbitrary point by an angle, given in degrees Read more