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

        var length = array.length / dimensions;
        var pointsArr = new Array(length);

        var k = 0;
        for(var i = 0; i < array.length; i += dimensions) {
            var point = new Array(dimensions);
            for(var j = 0; j < dimensions; ++j) {
                point[j] = array[i + j];
            }

            pointsArr[k] = point;
            k++;
        }

        return pointsArr;
    }
Function that returns an array of points given 1D array as follows:

[x1, y1, .. , x2, y2, ..]

And receive the number of dimensions of each point.
@param array
@param dimensions
@returns {Array} - Array of points.