Struct bevy_math::primitives::RegularPolygon
source · pub struct RegularPolygon {
pub circumcircle: Circle,
pub sides: usize,
}
Expand description
A polygon where all vertices lie on a circle, equally far apart.
Fields§
§circumcircle: Circle
The circumcircle on which all vertices lie
sides: usize
The number of sides
Implementations§
source§impl RegularPolygon
impl RegularPolygon
sourcepub fn new(circumradius: f32, sides: usize) -> Self
pub fn new(circumradius: f32, sides: usize) -> Self
Create a new RegularPolygon
from the radius of the circumcircle and a number of sides
Panics
Panics if circumradius
is non-positive
sourcepub fn circumradius(&self) -> f32
pub fn circumradius(&self) -> f32
Get the radius of the circumcircle on which all vertices of the regular polygon lie
sourcepub fn inradius(&self) -> f32
pub fn inradius(&self) -> f32
Get the inradius or apothem of the regular polygon. This is the radius of the largest circle that can be drawn within the polygon
sourcepub fn side_length(&self) -> f32
pub fn side_length(&self) -> f32
Get the length of one side of the regular polygon
sourcepub fn perimeter(&self) -> f32
pub fn perimeter(&self) -> f32
Get the perimeter of the regular polygon. This is the sum of its sides
sourcepub fn internal_angle_degrees(&self) -> f32
pub fn internal_angle_degrees(&self) -> f32
Get the internal angle of the regular polygon in degrees.
This is the angle formed by two adjacent sides with points within the angle being in the interior of the polygon
sourcepub fn internal_angle_radians(&self) -> f32
pub fn internal_angle_radians(&self) -> f32
Get the internal angle of the regular polygon in radians.
This is the angle formed by two adjacent sides with points within the angle being in the interior of the polygon
sourcepub fn external_angle_degrees(&self) -> f32
pub fn external_angle_degrees(&self) -> f32
Get the external angle of the regular polygon in degrees.
This is the angle formed by two adjacent sides with points within the angle being in the exterior of the polygon
sourcepub fn external_angle_radians(&self) -> f32
pub fn external_angle_radians(&self) -> f32
Get the external angle of the regular polygon in radians.
This is the angle formed by two adjacent sides with points within the angle being in the exterior of the polygon
sourcepub fn vertices(self, rotation: f32) -> impl IntoIterator<Item = Vec2>
pub fn vertices(self, rotation: f32) -> impl IntoIterator<Item = Vec2>
Returns an iterator over the vertices of the regular polygon, rotated counterclockwise by the given angle in radians.
With a rotation of 0, a vertex will be placed at the top (0.0, circumradius)
.
Trait Implementations§
source§impl Bounded2d for RegularPolygon
impl Bounded2d for RegularPolygon
source§fn aabb_2d(&self, translation: Vec2, rotation: f32) -> Aabb2d
fn aabb_2d(&self, translation: Vec2, rotation: f32) -> Aabb2d
source§fn bounding_circle(&self, translation: Vec2, _rotation: f32) -> BoundingCircle
fn bounding_circle(&self, translation: Vec2, _rotation: f32) -> BoundingCircle
source§impl Clone for RegularPolygon
impl Clone for RegularPolygon
source§fn clone(&self) -> RegularPolygon
fn clone(&self) -> RegularPolygon
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RegularPolygon
impl Debug for RegularPolygon
source§impl Default for RegularPolygon
impl Default for RegularPolygon
source§fn default() -> Self
fn default() -> Self
Returns the default RegularPolygon
with six sides (a hexagon) and a circumradius of 0.5
.
source§impl<'de> Deserialize<'de> for RegularPolygon
impl<'de> Deserialize<'de> for RegularPolygon
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for RegularPolygon
impl PartialEq for RegularPolygon
source§fn eq(&self, other: &RegularPolygon) -> bool
fn eq(&self, other: &RegularPolygon) -> bool
self
and other
values to be equal, and is used
by ==
.