Skip to main content
← All posts

Part 3: Circle Generation: Cartesian, Polar Coordinates & 8-Way Symmetry

Md. Harun-Or-RoshidNov 5, 20263 min readArticle
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:

x^2 + y^2 = r^2

Solving explicitly for $y$ yields:

y = \pm \sqrt{r^2 - x^2}

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)$:

x = x_c + r \cdot \cos(\theta), \quad y = y_c + r \cdot \sin(\theta)

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:

OctantAngular RangeReflected Pixel $(X, Y)$Plot Operation
Octant 1 (Base)45° to 90°(x, y)setPixel(xc + x, yc + y)
Octant 20° to 45°(y, x)setPixel(xc + y, yc + x)
Octant 3315° to 360°(y, -x)setPixel(xc + y, yc - x)
Octant 4270° to 315°(x, -y)setPixel(xc + x, yc - y)
Octant 5225° to 270°(-x, -y)setPixel(xc - x, yc - y)
Octant 6180° to 225°(-y, -x)setPixel(xc - y, yc - x)
Octant 7135° to 180°(-y, x)setPixel(xc - y, yc + x)
Octant 890° 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.

Share:
Share on X
Share on LinkedIn
Share on Facebook
Share on Reddit
Share on WhatsApp
Share on Telegram
Copy link

Related reading

Circle Generation: Polar & 8-Way Symmetry | Draftsbook · Draftsbook