2082 1

BIT304 · 2082 · 10 marks

Bresenham's Circle Drawing Algorithm & DDA Line Algorithm Trace

Bresenham's Circle Drawing Algorithm & DDA Line Algorithm Trace [10]

Computer GraphicsChapter 3: Line and Circle Drawing AlgorithmsDDA line drawing algorithmNumerical: DDA line drawing algorithm

Model Answer: Bresenham's Circle Drawing Algorithm & DDA Line Trace [10 marks]

Given Data (Extracted)

Part B (numeric):

  • Start point: $(x_1, y_1) = (2, 2)$
  • End point: $(x_2, y_2) = (6, 6)$

Part A is descriptive (no numeric inputs required).


Part A: Bresenham's Circle Drawing Algorithm [5 marks]

Definition: Bresenham's circle drawing algorithm is an efficient scan-conversion technique that plots the pixels closest to a true circle using only integer arithmetic. It uses the eight-way symmetry of a circle, so it computes points only for one octant ($0°$ to $45°$) and reflects them to the other seven.

Eight-Way Symmetry: For a point $(x, y)$ on a circle centered at origin, the following also lie on the circle:

$$(x, y),\ (-x, y),\ (x, -y),\ (-x, -y),\ (y, x),\ (-y, x),\ (y, -x),\ (-y, -x)$$

Algorithm Steps:

  1. Input radius $r$ and center $(x_c, y_c)$.
  2. Initialize starting point: $x = 0,\ y = r$.
  3. Compute initial decision parameter: $p_0 = 3 - 2r$.
  4. At each step, test $p_k$:
    • If $p_k < 0$: next point is $(x_k + 1,\ y_k)$ and $p_{k+1} = p_k + 4x_k + 6$
    • If $p_k \ge 0$: next point is $(x_k + 1,\ y_k - 1)$ and $p_{k+1} = p_k + 4(x_k - y_k) + 10$
  5. Plot all 8 symmetric points, translated by adding $(x_c, y_c)$.
  6. Repeat steps 4-5 until $x \ge y$.

Advantages:

  • Uses only integer addition/subtraction (no multiplication or trigonometry)
  • Fast and hardware-friendly
  • Produces smooth, symmetric circles

Part B: DDA Algorithm Trace - Line from $(2, 2)$ to $(6, 6)$ [5 marks]

Step 1: Compute differences: $$dx = x_2 - x_1 = 6 - 2 = 4$$ $$dy = y_2 - y_1 = 6 - 2 = 4$$

Step 2: Number of steps: $$steps = \max(|dx|, |dy|) = \max(4, 4) = 4$$

Step 3: Increments: $$x_{inc} = \frac{dx}{steps} = \frac{4}{4} = 1, \qquad y_{inc} = \frac{dy}{steps} = \frac{4}{4} = 1$$

Step 4: Iteration Table:

Step$x$$y$Pixel Plotted $(\text{round}(x), \text{round}(y))$
02.02.0(2, 2)
13.03.0(3, 3)
24.04.0(4, 4)
35.05.0(5, 5)
46.06.0(6, 6)

Explanation: Slope $m = \dfrac{dy}{dx} = \dfrac{4}{4} = 1$ (a $45°$ line). Both $x$ and $y$ increase by exactly 1 each step, giving a perfect diagonal.

Result: Pixels plotted: $(2,2), (3,3), (4,4), (5,5), (6,6)$ - five pixels forming a continuous diagonal line.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.