[−][src]Struct myelin_engine::prelude::Polygon
A convex polygon.
Can either be constructed using a PolygonBuilder
or with Polygon::try_new.
Methods
impl Polygon[src]
pub fn try_new(vertices: Vec<Point>) -> Result<Polygon, ()>[src]
Creates a new Polygon from the given Points.
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) -> Polygon[src]
Apply translation specified by translation, represented as
a relative point
pub fn rotate_around_point(&self, rotation: Radians, point: Point) -> Polygon[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 Intersects<Polygon> for Polygon[src]
fn intersects(&self, other: &Polygon) -> bool[src]
Returns wether this polygon touches, contains or is contained in another polygon
impl From<Aabb> for Polygon[src]
impl PartialEq<Polygon> for Polygon[src]
impl Default for Polygon[src]
impl Debug for Polygon[src]
impl<'de> Deserialize<'de> for Polygon[src]
fn deserialize<__D>(
__deserializer: __D
) -> Result<Polygon, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>, [src]
__deserializer: __D
) -> Result<Polygon, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl Clone for Polygon[src]
fn clone(&self) -> Polygon[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl Serialize for Polygon[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer, [src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>, [src]
T: Deserialize<'de>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>, [src]
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>[src]
fn is_in_subset(&self) -> bool[src]
unsafe fn to_subset_unchecked(&self) -> SS[src]
fn from_subset(element: &SS) -> SP[src]
impl<T> Downcast for T where
T: Any,
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> UserData for T where
T: Send + Sync + Clone + Any, [src]
T: Send + Sync + Clone + Any,