//this distributes the points based on 'sides' of the shorter path //this results in a more accurate final shape, but the transition is often not as clean function shapeTweenSides(shape1, shape2, findStart) { var fromShape = [], toShape = [], newShape = []; //make sure fromShape is the longer array if (shape1.length > shape2.length) { fromShape = shape1; toShape = shape2; } else { fromShape = shape2; toShape = shape1; } //make sure the orientation of the shapes match if (d3.polygonArea(fromShape) < 0 != d3.polygonArea(toShape) < 0) toShape.reverse(); //calculate how many sides on toShape and how many points per side in order to have a matching number of points var sides = toShape.length; var stepsPerSide = Math.floor(fromShape.length/sides); //cycle through each side, adding points along that side's path for (i=0; i