Part 3: Circle Generation: Cartesian, Polar Coordinates & 8-Way Symmetry
Curved Primitive Rasterization
A circle is defined mathematically as the locus of all coplanar points equidistant from a fixed center $(x_c, y_c)$. Unlike straight lines where the slope $m$ remains invariant throughout the segment, the slope of a circle changes continuously from $0$ to $\pm \infty$. Generating circles on discrete raster grids presents unique computational bottlenecks involving trigonometric evaluations and square roots. In this installment, we evaluate Cartesian polynomial equations, polar trigonometric formulations, and introduce the fundamental optimization of 8-way octant symmetry.
1. Cartesian Polynomial Representation
In Cartesian coordinates, a circle centered at origin $(0, 0)$ with radius $r$ satisfies the Pythagorean relation:
Solving explicitly for $y$ yields:
A straightforward scan-conversion routine steps $x$ in integer increments from $-r$ to $+r$ and evaluates $y = \text{round}(\sqrt{r^2 - x^2})$. However, this naive approach suffers from two severe architectural flaws:
- High Computational Latency: The square root function is computationally expensive in floating-point ALU pipelines and cannot be vectorized efficiently.
- Non-Uniform Pixel Density & Spacing: As $x$ approaches $r$, the derivative $\frac{dy}{dx} = -\frac{x}{\sqrt{r^2 - x^2}} \to -\infty$. The vertical change $\Delta y$ between consecutive unit steps in $x$ becomes arbitrarily large, leaving glaring pixel gaps along the steep circular perimeter.
2. Polar Trigonometric Coordinates
To overcome the uneven spacing of the Cartesian formula, a circle can be parameterized in polar coordinates $(\theta, r)$:
By stepping the angular parameter $\theta$ from $0$ to $2\pi$ in uniform angular increments $\Delta \theta$, points are distributed along the perimeter with constant arc-length separation $\Delta s = r \cdot \Delta \theta$. To prevent gaps, the step size must be set to $\Delta \theta \le \frac{1}{r}$.
Bottleneck: Although polar plotting guarantees uniform coverage without gaps, evaluating cos() and sin() functions at thousands of angular steps demands hundreds of clock cycles per pixel in software, rendering it entirely impractical for real-time rendering.
3. The Principle of 8-Way Octant Symmetry
A circle possesses continuous rotational and reflective symmetry. In a 2D Cartesian grid, a circle centered at $(0, 0)$ exhibits 8-way symmetry across the axes $x=0$, $y=0$, and the diagonals $y=x$, $y=-x$.
This means if a single pixel coordinate $(x, y)$ is calculated within the first octant (where $0 \le x \le y$, corresponding to $\theta \in [\frac{\pi}{4}, \frac{\pi}{2}]$), the remaining seven symmetrical pixels can be plotted immediately through coordinate reflection and permutation:
| Octant | Angular Range | Reflected Pixel $(X, Y)$ | Plot Operation |
|---|---|---|---|
| Octant 1 (Base) | 45° to 90° | (x, y) | setPixel(xc + x, yc + y) |
| Octant 2 | 0° to 45° | (y, x) | setPixel(xc + y, yc + x) |
| Octant 3 | 315° to 360° | (y, -x) | setPixel(xc + y, yc - x) |
| Octant 4 | 270° to 315° | (x, -y) | setPixel(xc + x, yc - y) |
| Octant 5 | 225° to 270° | (-x, -y) | setPixel(xc - x, yc - y) |
| Octant 6 | 180° to 225° | (-y, -x) | setPixel(xc - y, yc - x) |
| Octant 7 | 135° to 180° | (-y, x) | setPixel(xc - y, yc + x) |
| Octant 8 | 90° to 135° | (-x, y) | setPixel(xc - x, yc + y) |
4. Architectural Impact on Rendering Systems
By exploiting 8-way symmetry, a circle rasterizer only needs to compute pixel points across an arc of $45^\circ$ ($1/8\text{th}$ of the circumference). Once $x = y$ is reached, the octant is fully traversed and the loop terminates. This cuts computational workload by 87.5%.
However, combining 8-way symmetry with high-speed rendering requires eliminating floating-point math entirely. In the next part, we apply this symmetry directly to the optimal Midpoint Circle Algorithm.
Related reading
Part 11: 3D Graphics: Parallel & Perspective Projections & Hidden Surface Removal
A masterclass in 3D rendering pipelines, parallel and perspective projections, vanishing points, back-face culling, and GPU hardware Z-buffer depth testing.
By Md. Harun-Or-Roshid
Part 10: Interactive Graphics & Computer Animation: Input Devices & Keyframes
A study of interactive input architectures and animation principles, covering logical input devices, keyframing, tweening, and cubic Bezier curve interpolation.
By Md. Harun-Or-Roshid
Part 9: Clipping Algorithms: Cohen-Sutherland Line & Sutherland-Hodgman Polygon
A deep analysis of 2D geometric clipping algorithms, detailing Cohen-Sutherland 4-bit region outcodes and Sutherland-Hodgman sequential polygon clipping.
By Md. Harun-Or-Roshid
Part 8: 2D Viewing Pipeline: Window-to-Viewport Transformation Coordinates
A study of the 2D viewing transformation pipeline, detailing coordinate normalization, world window to viewport scaling derivation, and aspect ratio preservation.
By Md. Harun-Or-Roshid