Skip to main content

Posts

Showing posts with the label Computer Graphics

Bresenham’s Line Algorithm

             Bresenham’s Line Algorithm  Bresenham’s Line Algorithm: The Bresanhan’s Line Algorithm is one of the scan line algoirthm. The big advantege of Bresanham’s line Algorithm is that it is use only integer calculation. Algorithm : step1 : input two end point of line,showing the left end point A(X0 , Y0) and B(X1 , Y1) step2 : plot the point (X0 , Y0) Step3 : Calculate dx , dy, 2dx , 2dy and 2dx – 2dy dx = X1 -X0 dy = Y1 – Y0 2dx = 2( x1 -x0 ) 2dy = 2( Y1 – Y0 ) Po = 2dy – dx step 4 : taking k= 0 ; if (Pk <0 ) then next point is ( Xk+i , y1) ; and Pk+1 = Pk + 2dy ; else point is (Xk , Yk+i) Pk+1 = pk + 2(dx – dy ) step5 : Repeat step 4 (dx -1) times

Digital differential analyzer( DDA Algorithm)

                         DDA ALGORITHM DDA Algorithm: DDA Algorithm stand for Digital Differential Analyzer Algorithm. DDA Algorithm is the simple line generation algorithm. Let’s what is DDA algorithm on simple way Algorithm: Step1 : Get Input of two end point A(X0 , Y0) and B(X1 , Y1) Step2 : Calculate the Difference Between two point dx and dy dx = X1 – X0 dy = Y1 – Y0 step 3 : if dx > dy , then you need move step in X Coordinate, otherwise in Y coordinate if ( dx>dy)     step=dx ; else     step = dy ; step4 : Calculate the increment X and Y coordinate  Xinc = dx / step ; Yinc = dy / step ; step5 : put the X coordinate and Y coordinate accordingly for ( int v = 0 ; v< step; v++) X= X+ Xinc ; Y = Y + Yinc; put...