Scan-Converting the Sphere: Circle In-Out Test

Kenny Hoff
6/17/97


Spheres on Pixel-Planes 4 ALWAYS have a circular silhouette when projected onto the viewplane. This is due to the fact that the pixels covered on the screen are approximated by a circle in the viewing plane. Normally a sphere would project to an ellipse in the viewing plane, but the circle approximation should be quite reasonable except under close viewing conditions or when an extreme wide field-of-view is used for perspective projection. Typically the spheres will be far enough way that this distortion will go unnoticed. The center is projected as normal and the radius is properly foreshortened. In order to make this fast we must take the implicit form of the circle in screen-space (pixel space) and linearize it for use in the linear expression evaluators.

Given the implicit form of a circle of radius r pixels centered about pixel point (a,b), we must expand and group in order to fit the form Ax+By+C:

  (x-a)2 + (y-b)2 = r2                           // original circle equation
  (x-a)2 + (y-b)2 - r2 = 0                       // implicit form
  (x2 - 2ax + a2) + (y2 - 2by + b2) - r2 = 0     // expanded form
  -2ax - 2by + (a2 + b2 - r2) - (-x2 - y2) = 0   // rearranged and grouped
  2ax + 2by + (r2 - a2 - b2) - (x2 + y2) = 0     // * -1
We now have the following form:
  Ax + By + C - Q = 0
  A = 2a
  B = 2b
  C = r2 - a2 - b2
  Q = x2 + y2
In order to linearize the expression the squared terms had to be grouped into a separate term called "Q". This value is precomputed for each (x,y) pixel location in a tile in a table called the Qbuffer.

In order to determine if a pixel is inside the circle we must evaluate the entire expression Ax+By+C-Q. If the result is greater-than or equal to zero, the pixel is inside circle (or on the border). We can rearrange this equation to make better use of the Qbuffer. The pixel is "enabled" if any of the following are true:

  (Ax + By + C - Q) >= 0
  (Ax + By + C) >= Q
  (Ax + By + C) >= Qbuffer(x,y)
We have now made effective use of the fast linear expression evaluator by rearranging the implicit form of the circle and by utilizing pixel memory for the Qbuffer.