###
More on circles

Yesterday I described circle-point and circle-circle intersection tests. These are very straightforward to do, and it is interesting to look at why this is so, as it can help solve other problems with circles.
There are two main ways to describe a circle mathematically. It can be described parametrically with the following formulae,

where (*a*, *b*) is the centre of the circle, *r* is the radius and *θ* is the angle around the circle anti-clockwise from the x axis. This is useful for drawing a circle but not suited for testing whether things intersect or overlap.

The other form is an equation, based on Pythagoras' theorem,

This is less useful for generating points but is the best form for intersection tests. For example a point (*x*_{0}, *y*_{0}) is contained in a circle if its distance to the centre of the circle is less than the radius, so if it satisfies the following inequality based on the above equation,

Two circles overlap if the distance between their centres is less than the sum of their radii. So if the circles are at (*a*_{0}, *b*_{0}) and (*a*_{1}, *b*_{1}) with radii *r*_{0} and *r*_{1}, the inequality is

With a small modification this can also be used to determine whether one circle contains another, so the smaller circle lies entirely __inside__ a larger one without touching it. The inequality for that is.

In all the inequalities if the less than sign is replaced with a equals side they become the condition for the point and circle or circles to be touching, although testing this has to be done with care due to rounding errors.

## No comments:

## Post a Comment