Consider Bresenham's line generation algorithm for a line with gradient…

2016

Consider Bresenham's line generation algorithm for a line with gradient greater than one, current point (xi, yi) and decision parameter di taken in the standard steep-line form d = 2dx − dy. The next point to be plotted (xi+1, yi+1) and the updated decision parameter di+1, for di < 0, are given as _______.

Answer: B. xi+1 = xi yi+1 = yi + 1 di+1 = di + 2dxConcept — Bresenham's line algorithm always advances one full pixel along the driving axis, the axis along which the line moves faster. At each step an…

  1. A.

    xi+1 = xi + 1
    yi+1 = yi
    di+1 = di + 2dy

  2. B.

    xi+1 = xi
    yi+1 = yi + 1
    di+1 = di + 2dx

  3. C.

    xi+1 = xi
    yi+1 = yi + 1
    di+1 = di + 2(dx − dy)

  4. D.

    xi+1 = xi + 1
    yi+1 = yi + 1
    di+1 = di + 2(dy − dx)

Attempted by 163 students.

Show answer & explanation

Correct answer: B

Concept — Bresenham's line algorithm always advances one full pixel along the driving axis, the axis along which the line moves faster. At each step an integer decision parameter picks between exactly two candidate pixels: the pixel that moves along the driving axis alone, and the diagonal pixel that also moves one unit along the other axis. A negative decision parameter selects the driving-axis-only pixel and a non-negative one selects the diagonal pixel, and each of the two choices carries its own fixed increment for the parameter.

Which axis drives — this is decided by the gradient. For |m| ≤ 1 the line runs faster than it rises, so x drives and the parameter is p = 2dy − dx. For |m| > 1 the line rises faster than it runs, so the roles of x and y are interchanged: y drives and the parameter becomes d = 2dx − dy. Interchanging the axes swaps dx with dy everywhere, including inside the increments.

Application — the stem fixes the gradient above one and the case di < 0.

  1. Gradient greater than one means y is the driving axis, so every step raises y by exactly one: yi+1 = yi + 1.

  2. With the axes interchanged the decision parameter is d = 2dx − dy, and its only job is to decide whether x advances as well.

  3. The given case is di < 0, which selects the driving-axis-only pixel — here the north pixel — so x is held: xi+1 = xi.

  4. The increment paired with that choice is the interchanged form of the x-driven “+2dy”, namely +2dx, so di+1 = di + 2dx.

  5. Putting the three together: for di < 0 the next plotted point is (xi, yi + 1) and the updated parameter is di + 2dx.

Cross-check — run the same two rules over the remaining cases and the contrasting triples fall out by value.

  • Same gradient, other case: for di ≥ 0 with gradient greater than one the diagonal pixel is taken, giving (xi + 1, yi + 1) with di+1 = di + 2(dx − dy). So the triple that holds x, raises y and adds 2(dx − dy) pairs the north move with the north-east increment.

  • Shallow gradient, both cases: for 0 < m < 1 the x-driven form applies, so p < 0 gives (xi + 1, yi) with p + 2dy, and p ≥ 0 gives (xi + 1, yi + 1) with p + 2(dy − dx). Those are the triples that keep y fixed, and the one that raises both coordinates with a 2(dy − dx) increment.

  • Geometric sanity check: with gradient greater than one the line rises faster than it runs, so a step that leaves y unchanged would immediately fall away from the line. Any triple with yi+1 = yi therefore belongs to the shallow-slope form, not to this one.

  • Note on notes written for the usual 0 < m < 1 case: they give xi+1 = xi + 1, yi+1 = yi, di+1 = di + 2dy for a negative decision parameter. That is the x-driven rule. This question fixes the gradient above one, which interchanges the roles of x and y, so dx and dy swap and the x-driven triple does not apply here.

  • Convention note: this item follows the standard Bresenham form in which the steep-line decision parameter is d = 2dx − dy, so a negative value selects the driving-axis-only pixel. Some texts present the same test with the opposite sign, writing the parameter as dy − 2dx; there the inequality flips and a negative value selects the diagonal pixel instead. Always read the sign of the parameter definition before applying a d < 0 rule.

Result — for a gradient greater than one and di < 0, the next point to be plotted is (xi, yi + 1) and the updated decision parameter is di+1 = di + 2dx.

Explore the full course: Nta Ugc Net Paper 2

Loading lesson…