So, I have a pretty cool project going on with a custom matrix but I’m having some troubles on how to create a spiral on a matrix. I want something that looks like this, but then center it in my matrix:

I’m already able to create pretty cool effects with this code which I found on the internet:

void plasma() {
static byte offset = 0; // counter for radial color wave motion
static int plasVector = 0; // counter for orbiting plasma center
// Calculate current center of plasma pattern (can be offscreen)
int xOffset = cos8(plasVector / 256);
int yOffset = sin8(plasVector / 256);
// Draw one frame of the animation into the LED array
for (int x = 0; x < 17; x++) {
for (int y = 0; y < 5; y++) {
byte color = sin8(sqrt(sq(((float)x - 7.5) * 10 + xOffset - 127) + sq(((float)y - 2) * 10 + yOffset - 127)) + offset);
leds[XY(x, y)] = CHSV(color, 255, 255);
}
}
offset++; // wraps at 255 for sin8
plasVector += 16; // using an int for slower orbit (wraps at 65536)
FastLED.show(); // send the contents of the led memory to the LEDs
}

By modifying the byte color line I was able to create some other cool effects, but I still haven’t found a way to get a function which can give me a nice spiral effect. Anyone has an idea how I could implement it?

The only thing I could figure out was that this mathematical function creates a nice spiral: y = x * tan ( ln ( sqrt{x^2+y^2} )+z ). Then x and y should be the x and y axis of the matrix and z should be the color and besides z the offset can be added

Grumpy_Mike:
What sort of matrix do you have? What is the resolution?
To get that sort of quality you will need very high resolution.

I have a custom matrix of 17 (width) and 5 (height), which I know can't pack an awful lot of detail. However, I was pretty surprised at how the code given in my first post looked and therefore I thought something that could resemble the photo should be possible.

Also, I'm using a program called Jinx! LED Matrix control which also has a spiral like effect and can control my matrix via ARTNET. However, I'm not able to find out how the program generates this spiral since there is no source code available... And even if I was able to find the source, I'm not sure if the WEMOS I'm using has the power to calculate a spiral.

When it is down to 17 by 5 I don’t think you have a worthwhile effect

Hmm, I think I wasn’t clear on what exactly I wanted. I want a spiral like effect on my matrix, something which looks a bit like the spiral shown. Not the image projected on my matrix.

So, a logarithmic spiral with a gradient which is dependent on the phase shift of the formula. Simply put, draw a heck of a lot of spiral functions and each new spiral has a different color and is just a mm off to the previous one (so called phase shift), flow the colors into each other and a rainbow spiral comes out. Then spin all of these functions, this is the effect I wanted. Since I thought it would be too hard to explain, a picture seemed to give more context.

Yes but it is going to be the same or at least very similar.

That image looks like a linear spiral not a log one.

A simple way to generate one is to use
X = R Cos(theta)
Y = R Sin(theta)
And then change theta and R with each plot for one arm and repeat with a small amount added to the initial theta.

Grumpy_Mike:
Yes but it is going to be the same or at least very similar.

That image looks like a linear spiral not a log one.

A simple way to generate one is to use
X = R Cos(theta)
Y = R Sin(theta)
And then change theta and R with each plot for one arm and repeat with a small amount added to the initial theta.

Hmm, I tried replacing my xOffset and yOffset with your given equations (used sin and cos not sin8 and cos8) and used offset as R and plasVector as theta but it didn't look pretty. I'm pretty sure I'm way overthinking this, so how can I implement these equations in my sketch?

Those formulae are just standard polar to Cartesian co-ordnates.

Post the code of what you have tried. Use Serial.print statements to make sure you are getting the right values. Remember that trig functions normally have their arguments in radians not degrees.