Determining if a point lies inside a circle.

How do we actually determine whether a point lies inside or outside a circle? This slide shows a method using the equation of the circle. Again, we assume the circle is centered on the origin, and write its equation as:

x2 + y2 = r2

Consider the function:

F(x,y) = x2 + y2 - r2

For all points (x,y) which lie on the circle, F(x,y) = 0.

The diagram on the left side of the slide illustrates a point lying inside the circle. In this case, F(x,y) < 0. On the right, the point lies outside the circle, and F(x,y) > 0.

The value of this function at the reference point P serves the same purpose as the value of the error term in the line-drawing algorithm.

It influences the choice of the next pixel. For efficiency reasons, we do not want to compute this function very often. We can compute the explicit form of this function once, when we draw the first pixel, and then use addition to update its value for subsequent pixels.

Back

Quit