Zaid bin shafi 19bcs9504
ASSITGMENT 1
COMPUTER GRAPHICS
Name :Zaid bin Shafi section:cse-20
Uid:19BCS9504 subject code:CST-305
Q2: Calculate the points between the starting point (5, 6) and ending point (13, 10).
Using DDA algorithm.
Solution-
Given-
Starting coordinates = (X0, Y0) = (5, 6)
Ending coordinates = (Xn, Yn) = (13, 10)
Step-01:
Calculate ΔX, ΔY and M from the given input.
ΔX = Xn – X0 = 13 – 5 = 8
ΔY =Yn – Y0 = 10 – 6 = 4
M = ΔY / ΔX = 4 / 8 = 0.50
Step-02:
Calculate the number of steps.
As |ΔX| > |ΔY| = 8 > 4, so number of steps = ΔX = 8
Zaid bin shafi 19bcs9504
Step-03:
As M < 1, so case-01 is satisfied.
Now, Step-03 is executed until Step-04 is satisfied.
Xp Yp Xp+1 Yp+1 Round off (Xp+1, Yp+1)
5 6 6 6.5 (6, 7)
7 7 (7, 7)
8 7.5 (8, 8)
9 8 (9, 8)
10 8.5 (10, 9)
11 9 (11, 9)
12 9.5 (12, 10)
13 10 (13, 10)
Zaid bin shafi 19bcs9504