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
sourceimpl<T: CoordNum> Triangle<T>
impl<T: CoordNum> Triangle<T>
pub fn to_array(&self) -> [Coordinate<T>; 3]
pub fn to_lines(&self) -> [Line<T>; 3]
sourcepub fn to_polygon(self) -> Polygon<T>
pub fn to_polygon(self) -> Polygon<T>
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
sourceimpl<T: CoordNum> TryFrom<Geometry<T>> for Triangle<T>
impl<T: CoordNum> TryFrom<Geometry<T>> for Triangle<T>
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.
impl<T: Copy + CoordNum> Copy for Triangle<T>
impl<T: Eq + CoordNum> Eq for Triangle<T>
impl<T: CoordNum> StructuralEq for Triangle<T>
impl<T: CoordNum> StructuralPartialEq for Triangle<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Triangle<T> where
T: RefUnwindSafe,
impl<T> Send for Triangle<T> where
T: Send,
impl<T> Sync for Triangle<T> where
T: Sync,
impl<T> Unpin for Triangle<T> where
T: Unpin,
impl<T> UnwindSafe for Triangle<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
