Computer Graphics algorithms
Computer Graphics algorithms
The Digital Differential Analyzer (DDA) Algorithm is a simple and efficient method used for
rasterizing lines in computer graphics. It is an incremental scan conversion method that calculates
intermediate points between two given endpoints to approximate a straight line.
1. Input: Start and end coordinates of the line: (X0,Y0)(X0,Y0) and (X1,Y1)(X1,Y1).
2. Calculate Differences:
ΔX=X1−X0
ΔY=Y1−Y0
3. Determine Steps:
Steps=max(∣ΔX∣,∣ΔY∣)
Xinc=ΔX/Steps
Yinc=ΔY/Steps
X=X+Xinc
• Y=Y+Yinc
Advantages:
• Simple to implement.
Disadvantages:
Algorithm Steps:
2. Calculate Differences:
ΔX=X1−X0
ΔY=Y1−Y0
P=2ΔY−ΔX
P=P+2ΔY
P=P+2ΔY−2ΔX
Algorithm Steps:
1. Input: The center of the circle (Xc,Yc) and the radius rr.
2. Initialize:
P=1−r
(Xc+x,Yc+y),(Xc−x,Yc+y),(Xc+x,Yc−y),(Xc−x,Yc−y)
(Xc+y,Yc+x),(Xc−y,Yc+x),(Xc+y,Yc−x),(Xc−y,Yc−x)
P=P+2x+1
P=P+2x−2y++1
Ellipse Equation:
x2/a2+y2/b2=1
Where:
The algorithm uses midpoint decision parameters to decide whether the next pixel should be
placed horizontally or diagonally.
Algorithm Steps:
• Start at (0,b)
P1=b2−a2b+(1/4)a