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

◆ grad8() [3/3]

static int8_t grad8 ( uint8_t hash,
int8_t x,
int8_t y,
int8_t z )
inlinestatic

Definition at line 183 of file noise.cpp.

183 {
184#if 0
185 switch(hash & 0xF) {
186 case 0: return (( x) + ( y))>>1;
187 case 1: return ((-x) + ( y))>>1;
188 case 2: return (( x) + (-y))>>1;
189 case 3: return ((-x) + (-y))>>1;
190 case 4: return (( x) + ( z))>>1;
191 case 5: return ((-x) + ( z))>>1;
192 case 6: return (( x) + (-z))>>1;
193 case 7: return ((-x) + (-z))>>1;
194 case 8: return (( y) + ( z))>>1;
195 case 9: return ((-y) + ( z))>>1;
196 case 10: return (( y) + (-z))>>1;
197 case 11: return ((-y) + (-z))>>1;
198 case 12: return (( y) + ( x))>>1;
199 case 13: return ((-y) + ( z))>>1;
200 case 14: return (( y) + (-x))>>1;
201 case 15: return ((-y) + (-z))>>1;
202 }
203#else
204
205 hash &= 0xF;
206
207 int8_t u, v;
208 //u = (hash&8)?y:x;
209 u = selectBasedOnHashBit( hash, 3, y, x);
210
211#if 1
212 v = hash<4?y:hash==12||hash==14?x:z;
213#else
214 // Verbose version for analysis; generates idenitical code.
215 if( hash < 4) { // 00 01 02 03
216 v = y;
217 } else {
218 if( hash==12 || hash==14) { // 0C 0E
219 v = x;
220 } else {
221 v = z; // 04 05 06 07 08 09 0A 0B 0D 0F
222 }
223 }
224#endif
225
226 if(hash&1) { u = -u; }
227 if(hash&2) { v = -v; }
228
229 return avg7(u,v);
230#endif
231}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
uint32_t z[NUM_LAYERS]
Definition Fire2023.ino:84
LIB8STATIC_ALWAYS_INLINE int8_t avg7(int8_t i, int8_t j)
Calculate an integer average of two signed 7-bit integers (int8_t).
Definition math8.h:306
uint16_t hash(int32_t x, int32_t y)
static int8_t selectBasedOnHashBit(uint8_t hash, uint8_t bitnumber, int8_t a, int8_t b)
Definition noise.cpp:164

References avg7(), selectBasedOnHashBit(), x, y, and z.

Referenced by inoise8_raw(), inoise8_raw(), and inoise8_raw().

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