FastLED 3.9.15
Loading...
Searching...
No Matches

◆ at_splat_extrapolate()

Tile2x2_u8 fl::Corkscrew::at_splat_extrapolate ( float i) const
private

Definition at line 132 of file corkscrew.cpp.hpp.

132 {
133 if (i >= mNumLeds) {
134 // Handle out-of-bounds access, possibly by returning a default
135 // Tile2x2_u8
136 FASTLED_ASSERT(false, "Out of bounds access in Corkscrew at_splat: "
137 << i << " size: " << mNumLeds);
138 return Tile2x2_u8();
139 }
140
141 // Use the splat function to convert the vec2f to a Tile2x2_u8
142 float i_floor = fl::floorf(i);
143 float i_ceil = fl::ceilf(i);
144 if (fl::almost_equal(i_floor, i_ceil)) {
145 // If the index is the same, just return the splat of that index
146 vec2f position = at_no_wrap(static_cast<fl::u16>(i_floor));
147 return splat(position);
148 } else {
149 // Interpolate between the two points and return the splat of the result
150 vec2f pos1 = at_no_wrap(static_cast<fl::u16>(i_floor));
151 vec2f pos2 = at_no_wrap(static_cast<fl::u16>(i_ceil));
152 float t = i - i_floor;
153 vec2f interpolated_pos = map_range(t, 0.0f, 1.0f, pos1, pos2);
154 return splat(interpolated_pos);
155 }
156}
fl::u16 mNumLeds
Definition corkscrew.h:223
vec2f at_no_wrap(fl::u16 i) const
float floorf(float value) FL_NOEXCEPT
Definition math.h:304
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max) FL_NOEXCEPT
Definition math.h:174
vec2< float > vec2f
Definition geometry.h:333
constexpr bool almost_equal(T a, T b, U tolerance) FL_NOEXCEPT
Definition math.h:90
Tile2x2_u8 splat(vec2f xy)
"Splat" as in "splat pixel rendering" takes a pixel value in float x,y coordinates and "splats" it in...
Definition splat.cpp.hpp:14
float ceilf(float value) FL_NOEXCEPT
Definition math.h:310

References fl::almost_equal(), at_no_wrap(), fl::ceilf(), fl::floorf(), fl::map_range(), mNumLeds, fl::splat(), and fl::t.

Referenced by calculateTileAtWrap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: