tl;dr Just give me the code! Here you go:

tl;dr Just give me the code! Here you go: https://gist.github.com/StefanPetrick/5e853bea959e738bc6c2c2026683e3a4

Hi everyone! 2d matrix effects are a nice thing to code - but this requires lots of physical leds and a strong power supply to feed them.

So why not creating a 2d effect with just a very small amout of leds?

Here is the idea: Imagine a virtual 256x256 matrix. And imagine a circle constisting of NUM_LEDS leds. Now place this circle on the virtual matrix. The circle can be mathematically described as 2 overlapping functions - a sinus on x and a cosinus wave on y. The angle position of every single led we know - assuming the circle consists of 256 angle units the absolute x/y position defined by the relative angle of the given led is uint8_t angle = (i * 255) / NUM_LEDS;

So long story short - my code does the following: Calculate one time a look up table which contains the x/y position of any led within the virtual 256x256 matrix. This allows to calculate the noise data only for the few positions we really need = it´s fast while it still has the precision of a high-res matrix.

Based on that it´s easy to move the noise field in any direction(s).

The code contains 3 independent examples: example_1 moves the content up and down while shifting it slowly to the side. example_2 moves just along one axis and example_3 moves along the z axis of the noise space. Of course this simple movements can be combined or described by more complex functions, or they could be controlled by audio or sensor data or anything else you can imagine.

The color mapping could be improved as well - I decided to use a simple HSV mapping in order to keep the code simple and easy readable for the beginning.

The code is meant to inspire you to play with it yourself and create nice animations even for a limited setup. That´s why I kept the code short. It´s about the idea and not so mutch about delivering a plug and play animation.

Questions, suggestions and comments are highly appreciated. Has the code enough comments to get the idea? Is it useful for you?

What will you create based on this mapping?
Looking foreward to seeing it!
https://www.youtube.com/watch?v=39gjBySdu3U&feature=youtu.be

Is your diffuser a pillow? It looks soft and squishy.

Brilliant Stephan, Just brilliant.

Today was crazy busy and I hope to have a look at your routine(s) over the next few days. . . .

Update: Cool. I’ve now converted that to palette lookup with smooth transitioning to a new one every 5 seconds and trying out mathematical variations of each of the variables.

@Freddie_Olivas The refelctor is a solid brown clay wall. :slight_smile:

Super smart!

Thanks, everyone! The laste time I played with this idea was already 2 years ago with only 32 leds in the circle. Back then I calculated the whole matrix data and picked afterwards the little data I really needed for the circle. Here the link to the post: https://plus.google.com/115124694226931502095/posts/YxazKtMd31M

@Stefan_Petrick ​ what a brilliant idea and code. Like it and will try it next time I’m in the hackerspace

Between Stefan’s routine and the following one by Mark Kriegsman, we’ve got some very cool possibilities:

Could this be done inverted with an outer facing and inner facing ring to double the size? granted there would be a thin circle in the middle of the field.

this is exactly what i needed to kick off the lighting for my halloween mask!! excellent work. as an aside, you can work with specific palettes by using:
CRGB color = ColorFromPalette( paletteVariable, index, bri);

instead of
CRGB color = CHSV(index, 255, bri);

hope that’s helpful to someone!

here’s v1.2.1 of my halloween mask with the plasma/noise from this example :smiley: thanks for the help!!

Could you walk me through the gist of this, maybe with a picture of your virtual matrix/functions? So the idea is that from some position on the circle you can re-create the effect of a square matrix? I’m not sure I follow, exactly but it’s interesting!

The idea is to use angular coordinates to create the same complex effects that would be a lot more challenging if using x/y – is that the gist?

@John_Hendy : Yes, the polar coordinates of the leds are transformed into x/y coordinates.
FastLED noise functions calculate a noise value for a given x/y/z value. So if the precalculated leds x/y coordinates are fed into the noise function the visible effect is basically the same as it would be on a 2 dimensional matrix - just with way less leds. Does that help?

In pictures: This is the circular function - alpha is defined by the led index. https://cewebs.cs.univie.ac.at/inf-lernmat/ss09/index.php?m=F&t=wikis&c=aresource&CEWebS_c=g1t9&CEWebS_type=image&CEWebS_file=Unbenannt3.jpg&CEWebS_what=Mathematische~32~Definition~32~der~32~Kreisfunktionen~32~Sinus~32~und~32~Cosinus&CEWebS_rev=40
And with integer math the result is this: https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/Circle_drawing_-Horn.svg/220px-Circle_drawing-_Horn.svg.png

Seriously what is that diffuser tho

@Ben_Camp Brown clay, seriously.

@Stefan_Petrick ​ just loaded this onto my infinity mirror circle clock thing. Looks really awesome. Thanks for sharing the code.

When I upload I get the error:

no matching function for call to ‘CFastLED::addLeds(CRGB [150], int)’

I’m a beginner and probably missing something obvious, but I’ve played around and Googled and can’t figure it out. Please help!

Wemos D1 Mini and WS2812B strip

@Cogwun Have you installed the FastLED library yet? If so, which version are you using?