Rasterizing Primitives: Know Where To Draw The Line
Rasterizing Primitives: Know Where To Draw The Line
Rasterization of Primitives
How to draw primitives?
Convert from geometric definition to
pixels
rasterization = selecting the pixels
Rasterization Algorithms
Algorithmics:
Line-drawing: Bresenham, 1965
Polygons: uses line-drawing
Circles: Bresenham, 1977
Possible extensions:
efficient drawing of parabolas, hyperbolas
Circle-drawing algorithm
nave algorithm
Bresenham algorithm
Extension by symmetry
Only works with -1 m 1:
m=3
m = 1/3
Problems
2 floating-point operations per pixel
Improvements:
compute y = m*p+d
For x=xmin to xmax
y += m
light pixel (x,y)
or that one
Bresenham algorithm
I need a criterion to pick between
them
Distance between line and center of
pixel:
the error associated with this pixel
Error pixel 2
Error pixel 1
Else:
draw the other pixel.
Error of current pixel = 1 - error
Bresenham algorithm:
summary
Several good ideas:
Very straightforward:
good for hardware implementation
good for assembly language
E
SE
If the midpoint between pixels is inside the circle,
E is closer, draw E
If the midpoint is outside, SE is closer, draw SE
Midpoint algorithm:
summary
Extension of line drawing algorithm
Test based on midpoint position
Position checked using function:
sign of (x2+y2-r2)
Conclusion
The basics of Computer Graphics:
drawing lines and circles