var d = require('euclidean-distance');
 
// d([0,0], [1,0]);
// // 1 
 
// d([0,0], [3,2]);
// 3.605551275463989 
 


// console.log(d([-7,-4,3], [17, 6, 2.5]));

// 26.004807247892 

// // This should be able to take any number of coordinate sets
// function point(array1, array2) {
// 	var midpoint;
// 	var x;
// 	var y;

// 	// Add X
// 	x = array1[0] + array2[0];

// 	// Add Y
// 	y = array1[1] + array2[1];

// 	midpoint = [x * .5, y * .5];

// 	return midpoint;
// }


// Take coordinate sets for two points of any amount of dimension and find the midpoint
function point(arrays) {
	var midpoint;
	var dimensions = [];

	// Push another value into the array for each dimension we have
	for (var i = 0; i < arrays[0].length; i++) {
		dimensions.push(0);
	};

	// Add up the coordinate point values for each dimension (X, Y, Z, etc,) 
	// and divide them by two
	for (var i = 0; i < arrays.length; i++) {
		dimensions[0] =	arrays[i][0] + dimensions[0];
		dimensions[1] =	arrays[i][1] + dimensions[1];
		dimensions[2] =	arrays[i][2] + dimensions[2];
	};

	midpoint = [dimensions[0] * .5, dimensions[1] * .5, dimensions[2] * .5];

	return midpoint;
}

var euclideanDistance = (d([-3,4,1], [2,1,1]));
var euclideanMidpoint = point([[1,4,3], [3,-2,3]]);

console.log('euclideanDistance: ' + euclideanDistance);
console.log('euclideanMidpoint: ' + euclideanMidpoint);

