Title: Lines
1Lines
- DDA Line Drawing, Antialiasing
2Line Drawing
- How does a machine go about drawing a line
defined by a mathematical representation (e.g.
vector, endpoints, parametric, etc.)? - How does the continuous line description get
converted to the discrete pixel representation. - Important part of Rasterization process
- Some common algorithms
- DDA
- Bresenhams
3DDA Algorithm
- Digital Differential Analyser a scan conversion
line algorithm - Based on calculating the rate of change of x or y
coordinates (Dx or Dy respectively) - Given two endpoints
- Step for the larger of length(x) or length(y)
- Starting at first endpoint increment by Dx or Dy
rounding off to the nearest pixel coordinate.
4void lineDDA (int xa, int ya, int xa, int xb)
int dx xb - xa, dy yb - ya, steps, k float
xIncr, yIncr, x xa, y ya if (
abs(dx)gtabs(dy) ) steps abs(dx) else steps
abs(dy) xIncr dx / (float) steps yIncr
dy / (float) steps drawPixel ( ROUND(x),
ROUND(y) ) for (k0 kltsteps k) x
xIncr y yIncr drawPixel(
ROUND(x), ROUND(y) )
5Antialiasing
- Distortion of information due to low-frequency
sampling - In raster images leads to jagged edges with
staircase effect - We can reduce effects by antialiasing methods to
compensate for undersampling
6Antialiasing by supersampling
7(No Transcript)