1. Rasterization
Rasterization is the process of converting geometric primitives (like lines, polygons) into pixels on a display screen.
- It is a fundamental step in rendering 2D and 3D graphics.
- The goal is to determine which pixels on the screen should be illuminated to best represent a line, circle, or polygon.
- For lines, we need efficient algorithms to decide pixel positions along the line path.
2. Line Drawing
Problem
- A line is defined by endpoints (x0,y0) and (x1,y1).
- On a raster display, we need to select discrete pixel positions to approximate the line.
- Simple slope-based methods may require floating-point operations and can be slow.
3. Bresenham’s Line Drawing Algorithm
Bresenham’s Algorithm is an efficient integer-based line rasterization algorithm.
- Uses only integer addition, subtraction, and comparison (no floating-point arithmetic).
- Ideal for fast and accurate line drawing in raster displays.
Algorithm Concept
- Consider a line with slope 0≤m≤1 (general case; other slopes are handled similarly).
- Start at pixel (x0,y0).
- Move one step in x each iteration.
- Decide whether to keep y the same or increment y by 1 based on a decision parameter p.
Steps
Initialization
Δx=x1−x0,Δy=y1−y0
p0=2Δy−Δx
- p0 is the initial decision parameter.
Iterative Step
For each xk from x0 to x1:
-
Plot pixel at (xk,yk)
-
If pk<0:
- Next pixel: (xk+1,yk)
- Update decision parameter:
pk+1=pk+2Δy
-
Else:
- Next pixel: (xk+1,yk+1)
- Update decision parameter:
pk+1=pk+2Δy−2Δx
- Repeat until reaching (x1,y1).
Advantages
- Uses integer calculations only → fast and suitable for hardware implementation.
- Produces accurate and visually continuous lines.
- Works for all line slopes with minor modifications.
Example
Line from (2,3) to (10,7):
- Δx=8,Δy=4
- Initial decision parameter: p0=2⋅4−8=0
- Start at (2,3), update pixel coordinates based on pk for each x-step.
5. Summary
| Aspect |
Description |
| Purpose |
Convert a line into pixels on raster display |
| Algorithm |
Bresenham’s line drawing algorithm |
| Operations |
Integer addition, subtraction, comparison (no floating-point) |
| Advantages |
Fast, accurate, hardware-friendly |
| Limitation |
Must handle different slopes separately |
Key Points:
- Rasterization converts continuous geometry to discrete pixels.
- Bresenham’s algorithm is efficient, integer-based, and widely used for line drawing.
- Variants exist for steep slopes, negative slopes, and 3D lines.