# Choosing the best map!

Hello, I have a cylinder with a 218 led strip wrapping from the bottom in a spiral.

I have tried a couple of different maps, but not sure how best to choose one. Any thoughts?

Below are the two maps I am testing:

function (pixelCount) {
var map = [];
var layers = 24;
var pixPerRing = 9;
for (layer = 0; layer < layers; layer++) {
for (i = 0; i < pixPerRing; i++) {
c = i / pixPerRing * Math.PI * 2
map.push([Math.cos(c), Math.sin(c), layer])
}
}
return map
}

function (pixelCount) {
var map = [];
numloops=24;
for (i = 0; i < pixelCount; i++) {
c = i / pixelCount * Math.PI * 2*numloops
map.push([Math.cos(c), Math.sin(c),i/pixelCount])
}
return map
}

Hi David!

I would assume the second one will give better results in most cases due to the continuity of the z dimension. The first map may “rip” if the strip is truly in a helix and a pattern swept something up Z.

One quick reminder that the world coordinates use the computer graphics convention where positive Y points down. If I’m remembering this correctly, it implies that your helix as defined will be wound clockwise when viewed from above and arranged with the first pixels on the bottom, at z=0.

Hi Jeff, thanks for the response!
My pixels are wound counter clockwize, starting at the bottom.
Would this map be correct then?

function (pixelCount) {
var map = [];
numloops=24;
for (i =pixelCount ; i >= 0; i–) {
c = i / pixelCount * Math.PI * 2*numloops
map.push([Math.cos(c), Math.sin(c),i/pixelCount])
}
return map
}

Unfortunately no, because now it’s counting down, from the top (last pixel to first) which would be Ok (the map would be fine, it doesn’t care, the first map point is still zero pixel, second is one, and so on) but the Z is going from top (pixelcount/pixelcount or 1) down to (0/pixelcount or 0)

So there is a neat trick you can use to fix this:

Add a minus sign to i/pixelcount…
Then it would count from -1 to 0, and the PB will renormalize that to 0…1

And you also want to stop at zero (i>0), not -1 (i>=0), in your loop… Pixelcount is actually one bigger (so if pixelcount is 50, if you start at zero, you’ll have 51 pixels if you include the last one. Vice versa, counting down, same problem)

Got it working, thanks!

1 Like