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

◆ noiseSphereHSV16()

HSV16 fl::noiseSphereHSV16 ( float angle,
float phi,
u32 time,
float radius = 1.0f )

Sphere noise functions - sample three z-slices for independent component evolution.

Generate HSV16 noise for a sphere pattern.

Samples three z-slices of 3D Perlin noise (at time, time+0x10000, time+0x20000) to create independent hue, saturation, and value components.

Parameters
angleAzimuth angle around the sphere (radians, 0 to 2π)
phiPolar angle from the north pole (radians, 0 to π)
timeAnimation time parameter
radiusNoise zoom level (level of detail). Larger values = coarser pattern, smaller = more detail (default 1.0)
Returns
HSV16 color with 16-bit components

Definition at line 94 of file noise.cpp.hpp.

94 {
95 // Convert spherical coordinates to cartesian
96 // angle: azimuth (0 to 2π), phi: polar angle from north pole (0 to π)
97 // x = sin(phi) * cos(angle)
98 // y = sin(phi) * sin(angle)
99 // z = cos(phi)
100 float sin_phi = fl::sinf(phi);
101 float cos_phi = fl::cosf(phi);
102 float x = sin_phi * fl::cosf(angle);
103 float y = sin_phi * fl::sinf(angle);
104 float z = cos_phi;
105
106 // Map cartesian values from [-1, 1] to [0, 0xFFFF]
107 // This ensures positive values for uint32_t conversion
108 u32 nx = static_cast<u32>((x + 1.0f) * 0.5f * radius * 0xffff);
109 u32 ny = static_cast<u32>((y + 1.0f) * 0.5f * radius * 0xffff);
110 u32 nz = static_cast<u32>((z + 1.0f) * 0.5f * radius * 0xffff);
111
112 // Sample three different t-slices for H, S, V components
113 // Using offsets 0x0, 0x10000, 0x20000 to separate them in noise space
114 u16 h = inoise16(nx, ny, nz, time);
115 u16 s = inoise16(nx, ny, nz, time + 0x10000);
116 u16 v = inoise16(nx, ny, nz, time + 0x20000);
117
118 return HSV16(h, s, v);
119}
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:93
fl::u16 inoise16(fl::u32 x, fl::u32 y, fl::u32 z, fl::u32 t)
fl::u64 time() FL_NOEXCEPT
Alias for millis64() - returns 64-bit millisecond time.
Definition chrono.h:346
float sinf(float value) FL_NOEXCEPT
Definition math.h:352
float cosf(float value) FL_NOEXCEPT
Definition math.h:358

References cosf(), inoise16(), sinf(), time(), x, y, and z.

Referenced by noiseSphereHSV8().

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