pub struct Polygon<const N: usize> {
pub radius: f64,
}Expand description
A polygon with a fixed number of points. Now openscad uses points to initialize polygons which is fine but not very ergonomic.
Fields§
§radius: f64Implementations§
Source§impl<const N: usize> Polygon<N>
impl<const N: usize> Polygon<N>
Sourcepub const fn with_radius(radius: f64) -> Self
pub const fn with_radius(radius: f64) -> Self
Create a regular polygon inscribed in a circle with the given radius.
Sourcepub const fn with_diameter(diameter: f64) -> Self
pub const fn with_diameter(diameter: f64) -> Self
Create a regular polygon inscribed in a circle with the given diameter.
Sourcepub fn with_side(length: f64) -> Self
pub fn with_side(length: f64) -> Self
side = (2 * r * sin(angle / 2.0)) where angle = 2 * PI / N So the radius is calculated as: radius = side / (2 * sin(PI / N))
pub fn with_apothem(apothem: f64) -> Self
pub fn side(&self) -> f64
pub fn apothem(&self) -> f64
pub fn radius(&self) -> f64
pub fn points(&self) -> IntoIter<DVec2, N>
pub fn points_array(&self) -> [DVec2; N]
pub fn sides( &self, ) -> Map<CircularTupleWindows<IntoIter<DVec2, N>, (DVec2, DVec2)>, impl FnMut((DVec2, DVec2)) -> [DVec2; 2]>
Trait Implementations§
Source§impl<'de, const N: usize> Deserialize<'de> for Polygon<N>
impl<'de, const N: usize> Deserialize<'de> for Polygon<N>
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<const N: usize> PartialEq for Polygon<N>
impl<const N: usize> PartialEq for Polygon<N>
Source§impl<const N: usize> TryFrom<PolygonDynamic> for Polygon<N>
Available on crate feature std only.
impl<const N: usize> TryFrom<PolygonDynamic> for Polygon<N>
Available on crate feature
std only.impl<const N: usize> Copy for Polygon<N>
impl<const N: usize> StructuralPartialEq for Polygon<N>
impl<const N: usize> TwoDimensional for Polygon<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for Polygon<N>
impl<const N: usize> RefUnwindSafe for Polygon<N>
impl<const N: usize> Send for Polygon<N>
impl<const N: usize> Sync for Polygon<N>
impl<const N: usize> Unpin for Polygon<N>
impl<const N: usize> UnsafeUnpin for Polygon<N>
impl<const N: usize> UnwindSafe for Polygon<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CenterObject for Twhere
T: Object,
impl<T> CenterObject for Twhere
T: Object,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ColorObject for Twhere
T: Object,
impl<T> ColorObject for Twhere
T: Object,
fn colored(self, color: impl ColorFormat) -> Colored<T>
Source§impl<T> DifferenceObject for Twhere
T: Object,
impl<T> DifferenceObject for Twhere
T: Object,
fn difference<Other: Object>(self, other: Other) -> Difference<Self, Other>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntersectionObject for Twhere
T: Object,
impl<T> IntersectionObject for Twhere
T: Object,
fn intersection<Other: Object>(self, other: Other) -> Intersection<Self, Other>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more