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) -> Polygon<N>
pub const fn with_radius(radius: f64) -> Polygon<N>
Create a regular polygon inscribed in a circle with the given radius.
Sourcepub const fn with_diameter(diameter: f64) -> Polygon<N>
pub const fn with_diameter(diameter: f64) -> Polygon<N>
Create a regular polygon inscribed in a circle with the given diameter.
Sourcepub fn with_side(length: f64) -> Polygon<N>
pub fn with_side(length: f64) -> Polygon<N>
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) -> Polygon<N>
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))>
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<Polygon<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Polygon<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<const N: usize> From<Polygon<N>> for PolygonDynamic
Available on crate feature std only.
impl<const N: usize> From<Polygon<N>> for PolygonDynamic
std only.Source§fn from(polygon: Polygon<N>) -> PolygonDynamic
fn from(polygon: Polygon<N>) -> PolygonDynamic
Source§impl<const N: usize> OpenscadCodegen for Polygon<N>
impl<const N: usize> OpenscadCodegen for Polygon<N>
Source§impl<const N: usize> PartialEq for Polygon<N>
impl<const N: usize> PartialEq for Polygon<N>
Source§impl<const N: usize> Serialize for Polygon<N>
impl<const N: usize> Serialize for Polygon<N>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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>
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§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T [ShaderType] for self. When used in [AsBindGroup]
derives, it is safe to assume that all images in self exist.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
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>(self, other: Other) -> Difference<Self, Other>where
Other: Object,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> ExportObject for Twhere
T: OpenscadCodegen,
impl<T> ExportObject for Twhere
T: OpenscadCodegen,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntersectionObject for Twhere
T: Object,
impl<T> IntersectionObject for Twhere
T: Object,
fn intersection<Other>(self, other: Other) -> Intersection<Self, Other>where
Other: Object,
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>
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>
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§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<T> LinearExtrudeObject for Twhere
T: TwoDimensional,
impl<T> LinearExtrudeObject for Twhere
T: TwoDimensional,
fn linear_extrude<T>(self, height: T) -> LinearExtrude<Self>
Source§impl<T> LinearPatternObject for T
impl<T> LinearPatternObject for T
Source§impl<T> MirrorObject for Twhere
T: Object,
impl<T> MirrorObject for Twhere
T: Object,
fn mirror<T>(self, x: T, y: T, z: T) -> Mirror<Self>
fn mirror_x<T>(self, x: T) -> Mirror<Self>
fn mirror_y<T>(self, y: T) -> Mirror<Self>
fn mirror_z<T>(self, z: T) -> Mirror<Self>
fn mirror_xy<T>(self, x: T, y: T) -> Mirror<Self>
fn mirror_xz<T>(self, x: T, z: T) -> Mirror<Self>
fn mirror_yz<T>(self, y: T, z: T) -> Mirror<Self>
Source§impl<T> OffsetObject for Twhere
T: TwoDimensional,
impl<T> OffsetObject for Twhere
T: TwoDimensional,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ProjectionObject<T> for Twhere
T: Object,
impl<T> ProjectionObject<T> for Twhere
T: Object,
fn project(self) -> Projection<Self>
Source§impl<T> RotateExtrudeObject for Twhere
T: TwoDimensional,
impl<T> RotateExtrudeObject for Twhere
T: TwoDimensional,
fn rotate_extrude(self) -> RotateExtrude<Self>where
Self: Sized,
Source§impl<T> RotateObject for Twhere
T: Object,
impl<T> RotateObject for Twhere
T: Object,
fn rotate<T>(self, x: T, y: T, z: T) -> Rotate<Self>
fn rotate_x<T>(self, x: T) -> Rotate<Self>
fn rotate_y<T>(self, y: T) -> Rotate<Self>
fn rotate_z<T>(self, z: T) -> Rotate<Self>
fn rotate_xy<T>(self, x: T, y: T) -> Rotate<Self>
fn rotate_yz<T>(self, y: T, z: T) -> Rotate<Self>
fn rotate_xz<T>(self, x: T, z: T) -> Rotate<Self>
Source§impl<T> ScaleObject for Twhere
T: Object,
impl<T> ScaleObject for Twhere
T: Object,
fn scale_uniform<T>(self, scaler: T) -> Scale<Self>
fn scale<T>(self, x: T, y: T, z: T) -> Scale<Self>
fn scale_x<T>(self, x: T) -> Scale<Self>
fn scale_y<T>(self, y: T) -> Scale<Self>
fn scale_z<T>(self, z: T) -> Scale<Self>
fn scale_xy<T>(self, x: T, y: T) -> Scale<Self>
fn scale_xz<T>(self, x: T, z: T) -> Scale<Self>
fn scale_yz<T>(self, y: T, z: T) -> Scale<Self>
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.