Computer Grphips
DDA Line
Algorithm
Roll No. : IC-2K23-29
Course : MCA (5th sem)
Submitted to : Dr. Basant Namdeo
Submitted By : Divya Sharma
Introduction to Line
Drawing A line is one of the most basic and important
graphic primitives
Computer screens are made of pixels → Lines
must be approximated
We need algorithms to determine which pixels
best represent a straight line
Challenges:
Pixel grid → Lines become approximations
Steep vs shallow slopes
Efficient and accurate calculations
DDA is one of the earliest and simplest
algorithms for this purpose
What is DDA?
Full form: Digital Differential Analyzer
An incremental line-generation method
Works by calculating small increments in x or
y direction
Uses floating-point arithmetic
Generates intermediate pixel positions
between two endpoints
Produces visually smooth lines
Mathematical Basis
A straight line satisfies the equation y = mx + c
But computing m and c repeatedly is costly
Instead, DDA uses incremental updates:
Next x = x + Δx
Next y = y + Δy
These increments ensure smooth movement from start to
end
Useful even when the slope is fractional or greater than 1
Computing the Increments
Given: Two endpoints (x₁, y₁) and (x₂, y₂)
Compute differences:
dx = x₂ – x₁
dy = y₂ – y₁
Determine number of steps:
steps = max(|dx|, |dy|)
Compute increments:
x_inc = dx / steps
y_inc = dy / steps
These values decide how much x and y change for each plotted point
Numerical Example:
Example: Draw a line from (2, 3) to (10, 8)
Calculations:
dx = 8
dy = 5
steps = max(8, 5) = 8
x_inc = 8 / 8 = 1
y_inc = 5 / 8 = 0.625
DDA Point Generation Table
STEPS X Y PLOTTED PIXEL (ROUNDED)
0 2 3 (2,3)
1 3 3.625 (3,4)
2 4 4.25 (4,4)
3 5 4.875 (5,5)
4 6 5.5 (6,6)
5 7 6.125 (7,6)
6 8 6.75 (8,7)
7 9 7.375 (9,7)
8 10 8 (10,8)
Visual Example:
Slope Considerations
Case 1: |m| < 1
x increases faster
Smaller increments in y
Case 2: |m| > 1
y increases faster
Smaller increments in x
DDA handles both cases automatically
Works for:
Steep lines
Gentle lines
Horizontal, vertical, and diagonal lines
Advantages and
Disadvantages
Advantages of DDA Disadvantages of DDA
Very simple and easy to implement Uses floating point → slower on
Works for all types of slopes hardware without FPU
Produces smooth and visually Rounding causes accumulated errors
consistent lines Less accurate than Bresenham’s
Excellent for teaching concepts of Integer Algorithm
raster graphics May produce small deviations for long
Good for moderate graphics lines
applications
Applications of DDA
2D graphics engines
Game development
CAD tools and drawing software
Graph plotting applications
Basic rasterization in early computer graphics
Summary:
DDA is an incremental line drawing algorithm
Computes steps based on dx, dy
Uses x_inc and y_inc for generating points
Simple but less efficient than integer-based algorithms
Foundation for understanding rasterization
Still widely used in teaching and conceptual graphics
Thank You