Checking the Boundaries of a Circle in JavaScript
From the equation
(x - a)2 + (y - b)2 = r2
;
It can be deduced that
y = b ± √(r2 - (x - a)2)
;
And conversely
x = a ± √(r2 - (y - b)2).
Hence, the boundaries of any circle lie in the range
b - √(r2 - (xexternal - a)2)
≤ y ≤
b + √(r2 - (xexternal - a)2)
and
a - √(r2 - (yexternal - b)2)
≤ x ≤
a + √(r2 - (yexternal - b)2)