lib/geometry.js
function getRandPointInLineSegment([ [ beginX, beginY ], [ endX, endY ] ]) {
	let smallX = beginX <= endX ? beginX : endX;
	let largeX = beginX >= endX ? beginX : endX;
	let smallY = beginY <= endY ? beginY : endY;
	let largeY = beginY >= endY ? beginY : endY;
	if (beginY === endY) return [ roundToFiveSignificantDigits(smallX + Math.random() * (largeX - smallX)), beginY ];
	if (beginX === endX) return [ beginX, roundToFiveSignificantDigits(smallY + Math.random() * (largeY - smallY)) ];
	let slope = roundToFiveSignificantDigits((beginY - endY) / (beginX - endX));
	let intercept = roundToFiveSignificantDigits((beginX * endY - endX * beginY) / (beginX - endX));
	let randX = roundToFiveSignificantDigits(smallX + Math.random() * (largeX - smallX));
	let randY = roundToFiveSignificantDigits(slope * randX + intercept);
	return [ randX, randY ];
}
function getRandPointInLineSegment([ [ beginX, beginY ], [ endX, endY ] ]) {
	let smallX = beginX <= endX ? beginX : endX;
	let largeX = beginX >= endX ? beginX : endX;
	let smallY = beginY <= endY ? beginY : endY;
	let largeY = beginY >= endY ? beginY : endY;
	if (beginY === endY) return [ roundToFiveSignificantDigits(smallX + Math.random() * (largeX - smallX)), beginY ];
	if (beginX === endX) return [ beginX, roundToFiveSignificantDigits(smallY + Math.random() * (largeY - smallY)) ];
	let slope = roundToFiveSignificantDigits((beginY - endY) / (beginX - endX));
	let intercept = roundToFiveSignificantDigits((beginX * endY - endX * beginY) / (beginX - endX));
	let randX = roundToFiveSignificantDigits(smallX + Math.random() * (largeX - smallX));
	let randY = roundToFiveSignificantDigits(slope * randX + intercept);
	return [ randX, randY ];
}
function getRandPointInLineSegment ( [ [ beginX , beginY ] , [ endX , endY ] ] ) { let smallX = beginX <= endX ? beginX : endX ; let largeX = beginX >= endX ? beginX : endX ; let smallY = beginY <= endY ? beginY : endY ; let largeY = beginY >= endY ? beginY : endY ; if ( beginY === endY ) return [ roundToFiveSignificantDigits ( smallX + Math . random ( ) * ( largeX - smallX ) ) , beginY ] ; if ( beginX === endX ) return [ beginX , roundToFiveSignificantDigits ( smallY + Math . random ( ) * ( largeY - smallY ) ) ] ; let slope = roundToFiveSignificantDigits ( ( beginY - endY ) / ( beginX - endX ) ) ; let intercept = roundToFiveSignificantDigits ( ( beginX * endY - endX * beginY ) / ( beginX - endX ) ) ; let randX = roundToFiveSignificantDigits ( smallX + Math . random ( ) * ( largeX - smallX ) ) ; let randY = roundToFiveSignificantDigits ( slope * randX + intercept ) ; return [ randX , randY ] ; }
Get a random point in given line segment

@method getRandPointInLineSegment
@param {Number[][]} - coordinates of begin and end points of the line segment
@return {Number[]} - coordinates of generated random point
Get a random point in given line segment