Speaking of cool articles,

Speaking of cool articles, here’s some links on demos/plasma that could be usable by FastLED authors:

http://lodev.org/cgtutor/plasma.html
http://www.flipcode.com/archives/The_Art_of_Demomaking-Issue_04_Per_Pixel_Control.shtml
http://www.mennovanslooten.nl/blog/post/72
http://www.bidouille.org/prog/plasma

In addition, I still have the Sept 1986 issue of Scientific American, where A.K. Dewdney’s Mathematical Recreations article ‘Wallpaper for the Mind’ shows some pretty cool visuals. I wrote a demo around that on my PC (long since gone).

Wow, these are great! Thanks, now you have to make a matrix and show this stuff off!

Very nice links.

The oldschool demoscene has a lot in common with Arduino/LED art, there’s a lot of wisdom there we can carry forward and adapt.

Now I’m interested in creating a concentric sinusoid starting from a point. A simple Google and this is what I found, it could be of interest regarding the physics behind a model like this:
http://hyperphysics.phy-astr.gsu.edu/hbase/sound/trawvcon.html#c1

If you’re going to play with
data = sin®
then you’re going to need r, and to get r, you’re going to need square root, because
r = sqrt( dx^2 + dy^2 )

So: FastLED has an integer square root routine, called sqrt16
uint8_t sqrt16( uint16_t );
which is about 3X faster than the generic Arduino library routine on AVR.

Dan often reminds me that if all you’re doing is comparing distances, there’s often no need to do the sqrt step at all. But here I think for circular sine waves, it is needed. Let us know what you put together!

libation.h will save us all!

Well, I can’t say where it’s leading us, but we sure are going to get there faster now.

as will colorutils.h and noise.h.

For the Too Bright Hat, I used:
steps++;
uint8_t dummy1 = 127 + fastSinLUT((int16_t)(column/scale+steps));
uint8_t dummy2 = 127 + fastSinLUT((int16_t)(row/scalefastSinLUT((int16_t)(steps/2))/2+column/scalefastCosLUT((int16_t)(steps/3))/2+steps));
uint8_t dummy3 = 127 + fastSinLUT((int16_t)((row/scalefastCosLUT((int16_t)(steps/2)))/4+(column/scalefastSinLUT((int16_t(steps/3)))/4+steps)));
uint16_t result = dummy1 + dummy2 + dummy3; // Between 0…765

And then scaled or companded that down to 0…255. As I’m not after subtlety, I used this plasma pattern for hue and just set brightness and saturation to maximum. I don’t have the timing to hand, but it happily runs 180 LEDs on a Teensy 3.0.

(fastSinLUT from http://forum.arduino.cc/index.php?topic=69723.0)
(And what’s the best way to post short snippets of code on G+?)

@Mark_Kriegsman I’m having trouble with the ‘square root routine’ (say that 3x fast).

unsigned int result = sqrt16(i);

is what i’m trying to use, but I encounter the sqrt16() routine is not declared in this scope error. Where is my flaw?

It’s a recent addition; try getting a fresh checkout of the v2.1 branch.

@Jez_Weston Post it to http://pastebin.com.

@Jez_Weston : FastLED V2.1 offers fast integer approximations for sines and cosines, in both
int16_t sin16( uint16_t );
and
uint8_t sin8( uint8_t );
styles. Worth a look, IMHO.

Definitely worth a look. Since they exist I never used my own lookup table again.

P.S. And sometimes the result of quadwave8, cubicwave8 or triwave8 looks even cooler…
I compared them here: https://www.youtube.com/watch?v=s2U99Zu-kYw

@Mark_Kriegsman r = sqrt( dx^2 + dy^2 )
the dx and dy are my matrix coordinates?

dx = x1 - x2
dy = y1 - y2

To compute the distance between two points, you need two points.

One might be “the coordinates of this pixel” and the other might be “the middle of the matrix”

dx stands for delta x, or “change in x”; same for dy.

@Mark_Kriegsman Could this be referred to as a vector? http://processing.org/tutorials/pvector/

Well, a vector has two points, same as a line segment, but with a vector, one is the beginning and the other is the end. With a line segment, there’s no directionality to it.

But basically, yes :slight_smile: