pub enum Shape3d {
Point(Vec3),
Line {
start: Vec3,
end: Vec3,
pixel_count: usize,
},
Grid {
start: Vec3,
horizontal_end: Vec3,
vertical_end: Vec3,
horizontal_pixel_count: usize,
vertical_pixel_count: usize,
serpentine: bool,
},
Arc {
center: Vec3,
axis_u: Vec3,
axis_v: Vec3,
start_angle_in_radians: f32,
end_angle_in_radians: f32,
pixel_count: usize,
},
}
Expand description
Enumeration of three-dimensional shape primitives.
Each variant represents a different type of 3D arrangement of LEDs.
Variants§
Point(Vec3)
A single point at the specified location.
Line
A line of LEDs from start
to end
with pixel_count
LEDs.
Fields
Grid
A grid of LEDs defined by three corners and dimensions.
Fields
Arc
An circular or elliptical arc in 3D.
Parametric form:
point(theta) = center + cos(theta) * axis_u + sin(theta) * axis_v
Plane and orientation:
- The arc lies in the plane spanned by
axis_u
andaxis_v
. axis_u
andaxis_v
must be non-colinear (not scalar multiples).- Theta = 0 lies along
axis_u
(i.e.center + axis_u
)- As theta increases, the point moves towards
axis_v
.
- As theta increases, the point moves towards
- Looking along
axis_u x axis_v
, rotation is counter-clockwise. Swap the two axes to flip direction. - To make a full circle/ellipse, set end = start + core::f32::consts::TAU.
How to choose axis_u
/ axis_v
:
- Circle of radius
r
in the XY plane:axis_u = (r, 0, 0)
axis_v = (0, r, 0)
- Circle of radius
r
in an arbitrary plane with unit basisu
,v
:axis_u = r * u
axis_v = r * v
- Ellipse with radii
rx
,ry
in a plane with unit basisu
,v
:axis_u = rx * u
axis_v = ry * v
Notes:
- Axes don’t need to be unit length or perpendicular; their lengths set the ellipse radii along their directions.
- The points returned by
shape::points()
of aShape3d::Arc
:- Will have uniform density if a circular arc
- Will not have uniform density if an elliptical arc, as the points correspond to
theta
.
Implementations§
Source§impl Shape3d
impl Shape3d
Sourcepub const fn pixel_count(&self) -> usize
pub const fn pixel_count(&self) -> usize
Returns the total number of pixels (LEDs) in this shape.
Sourcepub fn points(&self) -> Shape3dPointsIterator ⓘ
pub fn points(&self) -> Shape3dPointsIterator ⓘ
Returns an iterator over all points (LED positions) in this shape.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Shape3d
impl RefUnwindSafe for Shape3d
impl Send for Shape3d
impl Sync for Shape3d
impl Unpin for Shape3d
impl UnwindSafe for Shape3d
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromColor<T> for T
impl<T> FromColor<T> for T
Source§fn from_color(color: T) -> T
fn from_color(color: T) -> T
Converts from the source color type
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Converts into the target color type
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 moreSource§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.