function coordArrayToCoordMatrix(array, dimensions) {
        if(array.length % dimensions !== 0) {
            throw new RangeError('Dimensions number must be accordance with the size of the array.');
        }

        var coordinatesArray = new Array(dimensions);
        var points = array.length / dimensions;
        for (var i = 0; i < coordinatesArray.length; i++) {
            coordinatesArray[i] = new Array(points);
        }

        for(i = 0; i < array.length; i += dimensions) {
            for(var j = 0; j < dimensions; ++j) {
                var currentPoint = Math.floor(i / dimensions);
                coordinatesArray[j][currentPoint] = array[i + j];
            }
        }

        return coordinatesArray;
    }
Function that given an array as follows:
[x1, y1, .. , x2, y2, ..]

Returns an array as follows:
[[x1, x2, ..], [y1, y2, ..], [ .. ]]

And receives the number of dimensions of each coordinate.
@param array
@param dimensions
@returns {Array} - Matrix of coordinates