# Mapping a cone?

**URL:** <https://forum.electromage.com/t/mapping-a-cone/72>\
**Category:** Ideas and Tips\
**Created:** [September 12, 2019, 5:34am UTC](https://forum.electromage.com/t/mapping-a-cone/72 "2019-09-12T05:34:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![wizard](https://forum.electromage.com/user_avatar/forum.electromage.com/wizard/32/4_2.png) [@wizard](https://forum.electromage.com/u/wizard)\
**Post date:** [September 12, 2019, 1:59pm UTC](https://forum.electromage.com/t/mapping-a-cone/72/2 "2019-09-12T13:59:00Z")

</div>

Thats a bit harder. Its tempting to do something like [Mapping a Helix](https://forum.electromage.com/t/mapping-a-helix/71) except the radius shrinks or grows with the for loop’s `i` variable, but the pixel distance gets messed up.

I turned to a bit of googling and calculus. Found the formula for a conical helix, and then integrating to find the arc distance to space out pixels. I don’t have time to dig further to figure out how to find the radius and spacing to match a specific number of pixels given 7 loops, but it’s easy to play with the numbers until things get really close.

```auto
function (pixelCount) {
  loops = 7
  r = 7.3
  pixelSpacing = .5
  resolution = .000005 //controls the resolution of the integral
  a = Math.PI * 2 * loops
  map = []
  
  function conicalHelix(t, r, a) {
    z = t
    x = (1-t) * r * Math.cos(t * a)
    y = (1-t) * r * Math.sin(t * a)
    return [x,y,z]
  }
  
  function conicalHelixArcLength(t1, t2, r, a) {
    h1 = conicalHelix(t1, r, a)
    h2 = conicalHelix(t2, r, a)
    dh = [h1[0] - h2[0], h1[1] - h2[1], h1[2] - h2[2]]
    return Math.sqrt(dh[0]*dh[0] + dh[1]*dh[1] + dh[2]*dh[2])
  }
  
  for (t = 0, i = 0; i < pixelCount; i++) {
    //integrate arc lengths until we cover the distance to our next pixel
    l = 0;
    while (l < pixelSpacing) {
      l += conicalHelixArcLength(t, t+resolution, r, a)
      t += resolution
    }
    map.push(conicalHelix(t, r, a))
  }
  return map
}

```

 ![03%20AM](https://forum.electromage.com/uploads/default/original/1X/62e029f4b5ecdb86c977aedfdb20aaec23b3317d.png)

---

_[View the full topic](https://forum.electromage.com/t/mapping-a-cone/72)._
