This test can be made against a value of zero if the inital value of scaledFraction has 2*dx subtracted from it. Giving, outside the loop:OffsetScaledFraction = dx + 2*dy - 2*dx = 2*dy - dxand the inner loop becomesOffsetScaledFraction += 2*dy if (OffsetScaledFraction >= 0) { y = y + 1; fraction -= 2*dx; }We might as well double the values of dy and dx (this can be accomplished with either an add or a shift outside the loop). |
||||||
![]() |
Lecture 5 | Slide 15 | 6.837 Fall '00 | ![]() |