Position of a point relative to a circle

Whether a point is inside a circle, on it, or outside is found by substituting its coordinates into the circle's equation and comparing. Take x2+y2=25x^2 + y^2 = 25, with centre at the origin and radius 55.

The test

The square of the distance from a point to the centre is x2+y2x^2 + y^2. Compare this with the square of the radius.

ConditionPosition
x2+y2<25x^2 + y^2 < 25inside the circle
x2+y2=25x^2 + y^2 = 25on the circle
x2+y2>25x^2 + y^2 > 25outside the circle

Three points

Pointx2+y2x^2 + y^2Position
(1,2)(1, 2)55inside
(4,3)(4, 3)2525on the circle
(4,4)(4, 4)3232outside

Why compare the squares

Computing the distance itself leads to the same conclusion, of course: (1,2)(1, 2) lies 52.24\sqrt{5} \approx 2.24 from the centre, less than the radius. But distances are never negative, so comparing their squares preserves the order. Skipping the square root is faster and avoids the rounding error it would introduce, which is why the squared comparison is standard. Collision checks against circular hitboxes in games are written exactly this way.

Distance to the circle itself

The outside point (4,4)(4, 4) sits 325.66\sqrt{32} \approx 5.66 from the centre.

QuantityComputationValue
Nearest distance325\sqrt{32} - 50.66\approx 0.66
Farthest distance32+5\sqrt{32} + 510.66\approx 10.66

The line joining the point to the centre pierces the circle at exactly its nearest and its farthest points.

The general circle

For a circle of centre (a,b)(a, b) and radius rr, compare (xa)2+(yb)2(x - a)^2 + (y - b)^2 with r2r^2. The sign of the left side minus the right side gives the position directly: negative inside, zero on the circle, positive outside.

From a curve to a region

This test also illustrates how an inequality describes a region. The inequality x2+y2<25x^2 + y^2 < 25 describes the interior of the circle, a piece of the plane rather than a curve. One equation gives a curve; turning it into an inequality gives an area. It is the same relationship as between the line ax+by+c=0ax + by + c = 0 and the half-plane ax+by+c>0ax + by + c > 0.

The large dots on the graph are the inside point, the on-circle point, and the outside point.