# First attempts at a map - 3d lines

**URL:** <https://forum.electromage.com/t/first-attempts-at-a-map-3d-lines/1068>\
**Category:** Patterns and Code\
**Created:** [March 12, 2021, 7:48am UTC](https://forum.electromage.com/t/first-attempts-at-a-map-3d-lines/1068 "2021-03-12T07:48:20Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![bdm](https://forum.electromage.com/user_avatar/forum.electromage.com/bdm/32/2666_2.png) [@bdm](https://forum.electromage.com/u/bdm)\
**Post date:** [March 12, 2021, 5:58pm UTC](https://forum.electromage.com/t/first-attempts-at-a-map-3d-lines/1068/4 "2021-03-12T17:58:44Z")

</div>

For anyone wanting to see the map, this is it, with the corrected math for the segments. I don’ think I have any duplicated pixels with it.

```
function (pixelCount) {
  width = 55
  length = 60
  height = 30
   // generate wireframe of tabletop with backboard
   
  // a 3d adaptation of the 2d line function
  // x, y, z is the starting position
  // dx, dy, dz is how far each step is, 0=no movement, 1=move in positive direction, -1=move in negative direction
  // count is the number of steps

  
  function line (x, y, z, dx, dy, dz, count) { 
	var line = [];
	for (var i = 0; i < count; i++) {
		line.push([x + dx * i, y + dy * i, z + dz * i]);
	}
	return line;
  }

  var map = []
  // start at 0,0, move 1,0 for each pixel, lengthPixels
  // first long side of tabletop]
  map = map.concat(line(0, 0, 0, 1, 0, 0, length)) 
  
  //then moving down, assuming 1 pixel from above counts toward the widthPixels
  // start at lengthPixel,1, move 0,1 for each pixel, widthPixels
  // short, back side of tabletop
  map = map.concat(line(length,1, 0, 0, 1, 0, width)) 
  
  //then from the bottom right to bottom left
  //second long side of tabletop
  map = map.concat(line(length-1, width, 0, -1, 0, 0, length))
  
  //vertical leg up backboard
  map = map.concat(line(0, width, 1, 0, 0, 1, height))
  
  //second short side of tabletop, at higher *height
  map = map.concat(line(0, width-1, height, 0, -1, 0, width))

  // vertical leg down backboard
  map = map.concat(line(0, 0, height-1, 0, 0, -1, height-1))
    
  return map;
}
```

---

_[View the full topic](https://forum.electromage.com/t/first-attempts-at-a-map-3d-lines/1068)._
