[−][src]Struct myelin_geometry::Polygon
A convex polygon.
Can either be constructed using a PolygonBuilder
or with Polygon::try_new
.
Implementations
impl Polygon
[src]
pub fn try_new(vertices: Vec<Point>) -> Result<Self, ()>
[src]
Creates a new Polygon
from the given Point
s.
Errors
This method will return an error if the number of configured
vertices is less than three (as the resulting Polygon
would not be two-dimensional), or if the resulting Polygon
is not convex.
pub fn vertices(&self) -> &[Point]
[src]
Returns the vertices of the polygon
pub fn translate(&self, translation: Point) -> Self
[src]
Apply translation specified by translation
, represented as
a relative point
pub fn rotate_around_point(&self, rotation: Radians, point: Point) -> Self
[src]
Rotate polygon by a rotation
around a point
pub fn contains_point(&self, point: Point) -> bool
[src]
Checks if a given point rests inside the polygon
pub fn aabb(&self) -> Aabb
[src]
Returns an Aabb
which fully contains this polygon.
Panics
Panics if the floating-point values representing the vertices' coordinates
are not comparable, e.g. NaN
or if the polygon has no vertices.
The latter should never occur, because the constructor validates that the polygon is valid.
pub fn edges(&self) -> impl Iterator<Item = Vector> + '_
[src]
Returns the polygon's edges, i.e. the lines between vertices, as vectors.
Trait Implementations
impl Clone for Polygon
[src]
impl Debug for Polygon
[src]
impl Default for Polygon
[src]
impl<'de> Deserialize<'de> for Polygon
[src]
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl From<Aabb> for Polygon
[src]
impl Intersects<Polygon> for Polygon
[src]
pub fn intersects(&self, other: &Polygon) -> bool
[src]
Returns wether this polygon touches, contains or is contained in another polygon
impl PartialEq<Polygon> for Polygon
[src]
impl Serialize for Polygon
[src]
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Polygon
[src]
Auto Trait Implementations
impl RefUnwindSafe for Polygon
[src]
impl Send for Polygon
[src]
impl Sync for Polygon
[src]
impl Unpin for Polygon
[src]
impl UnwindSafe for Polygon
[src]
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<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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, 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>,