Get Distance

Measure Coordinate Distance

It's often necessary to measure the distance between two points in 2D space. This method takes the position of the two coordinates, x1, y1 first, to x2, y2 second, and returns the distance between them.

View example

function getDistance(x1, y1, x2, y2)
	return (Math.abs(Math.sqrt(((x1-x2) * (x1-x2)) +
		((y1-y2) * (y1-y2)))));

Page loaded in 0.012 second(s).