Struct geo::Triangle [−][src]
pub struct Triangle<T>(pub Coordinate<T>, pub Coordinate<T>, pub Coordinate<T>)
where
T: CoordNum;
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.
Implementations
impl<T> Triangle<T> where
T: CoordNum,
[src]
T: CoordNum,
pub fn to_array(&self) -> [Coordinate<T>; 3]
[src]
pub fn to_lines(&self) -> [Line<T>; 3]
[src]
pub fn to_polygon(self) -> Polygon<T>
[src]
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
impl<T> AbsDiffEq<Triangle<T>> for Triangle<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
[src]
T: AbsDiffEq<T, Epsilon = T> + CoordNum,
<T as AbsDiffEq<T>>::Epsilon: Copy,
type Epsilon = T
Used for specifying relative comparisons.
pub fn default_epsilon() -> <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon
[src]
pub fn abs_diff_eq(
&self,
other: &Triangle<T>,
epsilon: <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon
) -> bool
[src]
&self,
other: &Triangle<T>,
epsilon: <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon
) -> bool
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);
pub fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
impl<T> Area<T> for Triangle<T> where
T: CoordFloat,
[src]
T: CoordFloat,
fn signed_area(&self) -> T
[src]
fn unsigned_area(&self) -> T
[src]
impl<T> BoundingRect<T> for Triangle<T> where
T: CoordNum,
[src]
T: CoordNum,
type Output = Rect<T>
fn bounding_rect(&self) -> Self::Output
[src]
impl<T> Centroid for Triangle<T> where
T: GeoFloat,
[src]
T: GeoFloat,
impl<T> Clone for Triangle<T> where
T: Clone + CoordNum,
[src]
T: Clone + CoordNum,
impl<T> Contains<Coordinate<T>> for Triangle<T> where
T: GeoNum,
[src]
T: GeoNum,
fn contains(&self, coord: &Coordinate<T>) -> bool
[src]
impl<T> Contains<Point<T>> for Triangle<T> where
T: GeoNum,
[src]
T: GeoNum,
impl<F> Contains<Triangle<F>> for MultiPolygon<F> where
F: GeoFloat,
[src]
F: GeoFloat,
impl<T> CoordinatePosition for Triangle<T> where
T: GeoNum,
[src]
T: GeoNum,
type Scalar = T
fn calculate_coordinate_position(
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
[src]
&self,
coord: &Coordinate<T>,
is_inside: &mut bool,
boundary_count: &mut usize
)
fn coordinate_position(&self, coord: &Coordinate<Self::Scalar>) -> CoordPos
[src]
impl<'a, T: CoordNum + 'a> CoordsIter<'a> for Triangle<T>
[src]
type Iter = Chain<Chain<Once<Coordinate<T>>, Once<Coordinate<T>>>, Once<Coordinate<T>>>
type ExteriorIter = Self::Iter
type Scalar = T
fn coords_iter(&'a self) -> Self::Iter
[src]
fn coords_count(&'a self) -> usize
[src]
Return the number of coordinates in the Triangle
.
fn exterior_coords_iter(&'a self) -> Self::ExteriorIter
[src]
impl<T> Copy for Triangle<T> where
T: Copy + CoordNum,
[src]
T: Copy + CoordNum,
impl<T> Debug for Triangle<T> where
T: Debug + CoordNum,
[src]
T: Debug + CoordNum,
impl<T> Eq for Triangle<T> where
T: Eq + CoordNum,
[src]
T: Eq + CoordNum,
impl<T> EuclideanDistance<T, Point<T>> for Triangle<T> where
T: GeoFloat,
[src]
T: GeoFloat,
fn euclidean_distance(&self, point: &Point<T>) -> T
[src]
impl<IC, T> From<[IC; 3]> for Triangle<T> where
T: CoordNum,
IC: Into<Coordinate<T>> + Copy,
[src]
T: CoordNum,
IC: Into<Coordinate<T>> + Copy,
impl<T> From<Triangle<T>> for Geometry<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> From<Triangle<T>> for Polygon<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<C: GeoNum> HasDimensions for Triangle<C>
[src]
fn is_empty(&self) -> bool
[src]
fn dimensions(&self) -> Dimensions
[src]
fn boundary_dimensions(&self) -> Dimensions
[src]
impl<T> Hash for Triangle<T> where
T: Hash + CoordNum,
[src]
T: Hash + CoordNum,
pub fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, G> Intersects<G> for Triangle<T> where
T: CoordNum,
Polygon<T>: Intersects<G>,
[src]
T: CoordNum,
Polygon<T>: Intersects<G>,
fn intersects(&self, rhs: &G) -> bool
[src]
impl<T> Intersects<Triangle<T>> for Coordinate<T> where
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
[src]
Triangle<T>: Intersects<Coordinate<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
[src]
impl<T> Intersects<Triangle<T>> for Line<T> where
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
[src]
Triangle<T>: Intersects<Line<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
[src]
impl<T> Intersects<Triangle<T>> for Rect<T> where
Triangle<T>: Intersects<Rect<T>>,
T: CoordNum,
[src]
Triangle<T>: Intersects<Rect<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
[src]
impl<T> Intersects<Triangle<T>> for Polygon<T> where
Triangle<T>: Intersects<Polygon<T>>,
T: CoordNum,
[src]
Triangle<T>: Intersects<Polygon<T>>,
T: CoordNum,
fn intersects(&self, rhs: &Triangle<T>) -> bool
[src]
impl<T: CoordNum, NT: CoordNum> MapCoords<T, NT> for Triangle<T>
[src]
type Output = Triangle<NT>
fn map_coords(&self, func: impl Fn(&(T, T)) -> (NT, NT) + Copy) -> Self::Output
[src]
impl<T: CoordNum> MapCoordsInplace<T> for Triangle<T>
[src]
impl<T> PartialEq<Triangle<T>> for Triangle<T> where
T: PartialEq<T> + CoordNum,
[src]
T: PartialEq<T> + CoordNum,
pub fn eq(&self, other: &Triangle<T>) -> bool
[src]
pub fn ne(&self, other: &Triangle<T>) -> bool
[src]
impl<F: GeoFloat> Relate<F, GeometryCollection<F>> for Triangle<F>
[src]
fn relate(&self, other: &GeometryCollection<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Line<F>> for Triangle<F>
[src]
fn relate(&self, other: &Line<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, LineString<F>> for Triangle<F>
[src]
fn relate(&self, other: &LineString<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, MultiLineString<F>> for Triangle<F>
[src]
fn relate(&self, other: &MultiLineString<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, MultiPoint<F>> for Triangle<F>
[src]
fn relate(&self, other: &MultiPoint<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, MultiPolygon<F>> for Triangle<F>
[src]
fn relate(&self, other: &MultiPolygon<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Point<F>> for Triangle<F>
[src]
fn relate(&self, other: &Point<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Polygon<F>> for Triangle<F>
[src]
fn relate(&self, other: &Polygon<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Rect<F>> for Triangle<F>
[src]
fn relate(&self, other: &Rect<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for Point<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for Line<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for LineString<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for Polygon<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for MultiPoint<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for MultiLineString<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for MultiPolygon<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for Rect<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for Triangle<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<F: GeoFloat> Relate<F, Triangle<F>> for GeometryCollection<F>
[src]
fn relate(&self, other: &Triangle<F>) -> IntersectionMatrix
[src]
impl<T> RelativeEq<Triangle<T>> for Triangle<T> where
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
[src]
T: AbsDiffEq<T, Epsilon = T> + CoordNum + RelativeEq<T>,
pub fn default_max_relative(
) -> <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon
[src]
) -> <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon
pub fn relative_eq(
&self,
other: &Triangle<T>,
epsilon: <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon,
max_relative: <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon
) -> bool
[src]
&self,
other: &Triangle<T>,
epsilon: <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon,
max_relative: <Triangle<T> as AbsDiffEq<Triangle<T>>>::Epsilon
) -> bool
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);
pub fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon
) -> bool
impl<T> StructuralEq for Triangle<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> StructuralPartialEq for Triangle<T> where
T: CoordNum,
[src]
T: CoordNum,
impl<T> TryFrom<Geometry<T>> for Triangle<T> where
T: CoordNum,
[src]
T: CoordNum,
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.
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(
geom: Geometry<T>
) -> Result<Triangle<T>, <Triangle<T> as TryFrom<Geometry<T>>>::Error>
[src]
geom: Geometry<T>
) -> Result<Triangle<T>, <Triangle<T> as TryFrom<Geometry<T>>>::Error>
impl<T: CoordNum, NT: CoordNum> TryMapCoords<T, NT> for Triangle<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Triangle<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Triangle<T> where
T: Send,
T: Send,
impl<T> Sync for Triangle<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Triangle<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Triangle<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T, G> Extremes<'a, T> for G where
T: CoordNum,
G: CoordsIter<'a, Scalar = T>,
[src]
T: CoordNum,
G: CoordsIter<'a, Scalar = T>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, G> RotatePoint<T> for G where
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
[src]
T: CoordFloat,
G: MapCoords<T, T, Output = G>,
pub fn rotate_around_point(&Self, T, Point<T>) -> G
[src]
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, G> Translate<T> for G where
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
[src]
T: CoordNum,
G: MapCoords<T, T, Output = G> + MapCoordsInplace<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,