[ Contact ] [ Links ] [ Previous : 11 / 20 : Applications of Low-level Optimizations ] [ Up ] [ Next : 13 / 20 : More Low-level Optimizations (3) ]

More Low-level Optimizations (2)

Note that y is now an integer.
Can we represent the fraction as an integer?
After we draw the first pixel (which happens outside our main loop) the correct fraction is:

fraction = 1/2 + dy/dx

If we scale the fraction by 2*dx the following expression results:

scaledFraction = dx + 2*dy

and the incremental update becomes:

scaledFraction += 2*dy         // 2*dx*(dy/dx)

and our test must be modified to reflect the new scaling

if (scaledFraction >= 2*dx) { ... }

See the "Links" link above to find out the sources of the proposed informations
Pascal Vuylsteker / eScience / Computer Science / ANU
Last modified: 20/4/2004
TOC - Print
Send your comments at :
<Hugh.Fisher@anu.edu.au>