Amazon Affiliate

Tuesday 25 June 2013

Derivation of DDA Line Drawing Algorithm.

Derivation of DDA Line Drawing Algorithm.



DERIVATION :

                              Let Y = mX + c  --------------------------  (A)

 Differentiate (A) with respect to X

dY/dX = m

Where m is slope of the line and c is intercept.



Case 1 :

 m < 1

dY/dX  < 1

dY < dX

Large change in X make small change in Y


If dX = 1

dY = m

Xi+1 – Xi = 1

Xi+1 = Xi + 1

Yi+1 – Yi = m

Yi+1 = Yi + m

Case 2 :

m > 1

dY/dX  > 1

dY > dX

Large change in Y make small change in X

If dY = 1

dX = 1/m

Xi+1 – Xi = 1/m

Xi+1 = Xi + 1/m

Yi+1 – Yi = 1

Yi+1 = Yi + 1



Case 3 :

M = 1

dY = dX

Xi+1 – Xi = 1

Xi+1 = Xi + 1

Yi+1 – Yi = 1

Yi+1 = Yi + 1










 

7 comments: