Help with a pretty basic mapping layout of a hollow rectangle

Have a poke around with this. It divides the line between two points by the number of pixels along it, excluding the start and end point. My application had an equal number of pixels per side but you can replace the N value under ‘var map’ to whatever you want, they don’t have to be the same.


// Polymapper V1.0

function (pixelCount) {
  
  var N = 10

  function line(Ax, Ay, Az, Bx, By, Bz, N) {
    
    var dx = (Bx - Ax) / N;
    var dy = (By - Ay) / N;
    var dz = (Bz - Az) / N;
    
    var line = [];
    for (var i = 1; i < N; i++) {
      line.push([Ax + i*dx, Ay + i*dy, Az + i*dz]);
    }
    return line;
  }
  
  var map = [];
  
  map = map.concat(line(0, 0, 0, 0, 1, 0, N))
  map = map.concat(line(0, 1, 0, 1, 1, 0, N))
  map = map.concat(line(1, 1, 0, 1, 0, 0, N))
  map = map.concat(line(1, 0, 0, 1, 0, 1, N))
  map = map.concat(line(1, 0, 1, 1, 1, 1, N))
  map = map.concat(line(1, 1, 1, 0, 1, 1, N))
  map = map.concat(line(0, 1, 1, 0, 0, 1, N))
  map = map.concat(line(0, 0, 1, 0, 0, 0, N))
  
  return map;
}

3 Likes