Point in Circle

Test point in circle

A simple method for testing if a given point, described by a set of coordinates in a 2D plane, falls within the area of a circle provided its X and Y coordinates and radius.

View example

This method tests if the x (horizontal) difference squared plus the y (vertical) difference squared is less than or equal to the radius squared.

function pointInCircle(x, y, cx, cy, cr)
	var squareDist = ((cx - x) * (cx - x) + (cy - y) * (cy - y));
	return squareDist <= (cr * cr);

Page loaded in 0.007 second(s).