Spiral Christmas Tree

Hi guys,

I have PixelBlaze in my christmas tree. Have some LEDs in a sprial way up the tree. Wanted to map. 1st manuall, but that seems overkill. Tried to do a simple sprail, but that would render to much of the pixels close to the top.

Did some googling and found a good tipp on stackoverflow. Put everything into one piecce of code for your convenience.

Key advantage is that the LEDs are äquidistant over the whole string.

function (pixelCount) {
  
  var n = 3;
  var R = 1.0;
  var H = 1.0
  
  var s = Math.PI * 2 * n 
  var map = [];

  for (i = pixelCount; i > 0; i--) {
    b = i + 1
    t = 2 * Math.PI * Math.sqrt(s / b / pixelCount ) 
    r = R - b * t 
    map.push([Math.cos(i * t) * r , Math.sin(i * t) * r, H - H/pixelCount * i])
  }
  return map
}

You might find this usefull.

4 Likes