Showing posts with label Coumper Graphics. Show all posts
Showing posts with label Coumper Graphics. Show all posts

Sunday, 28 February 2016

DDA LINE ALGORITHM

DDA Line ( X1, Y1, XN, YN):
Description: Here X1 and Y1 denote the starting x – coordinate and y – coordinate of the line
and XN and YN denote the ending x – coordinate and y – coordinate.


1. Set M = (YN – Y1) / (XN – X1) [Calculate slope of line]
2. Repeat For I = X1 to XN
3. If (M <= 1) Then
4. Set DX = 1
5. Set DY = M * DX
6. Else
7. Set DY = 1
8. Set DX = DY / M
[End of If]
9. Set X1 = X1 + DX
10. Set Y1 = Y1 + DY
11. Call PutPixel(X1, Y1)
[End of For]
12. Exit

Monday, 22 February 2016

BRESENHAM’S LINE ALGORITHM

BRESENHAM’S LINE ALGORITHM

Bresenham Line ( X1, Y1, XN, YN):
Description: Here X1 and Y1 denote the starting x – coordinate and y – coordinate of the line
and XN and YN denote the ending x – coordinate and y – coordinate.

1. Set DX = XN – X1 and DY = YN – Y1
2. Set Di = 2DY - DX
3. Set DS = 2DY and DT = 2(DY – DX)
4. Call PutPixel(X1, Y1)
5. Repeat While (X1 < XN)
6. Set X1 = X1 + 1
7. If (Di < 0) Then
8. Set Di = Di + DS
9. Else
10. Set Y1 = Y1 + 1
11. Set Di = Di + DT
[End of If]
12. Call PutPixel(X1, Y1)
[End of While]
13. Exit

This is line ALGORITHM if you got any error please feel to comment.This Very easy to understand and learn. 

Sunday, 21 February 2016

BRESENHAM’S CIRCLE ALGORITHM

BRESENHAM’S CIRCLE ALGORITHM
Bresenham Circle ( Xc, Yc, R):
Description: Here Xc and Yc denote the x – coordinate and y – coordinate of the center of the
circle. R is the radius.
1. Set X = 0 and Y = R
2. Set D = 3 – 2R
3. Repeat While (X < Y)
4. Call Draw Circle(Xc, Yc, X, Y)
5. Set X = X + 1
6. If (D < 0) Then
7. D = D + 4X + 6
8. Else
9. Set Y = Y – 1
10. D = D + 4(X – Y) + 10
[End of If]
11. Call Draw Circle(Xc, Yc, X, Y)
[End of While]
12. Exit

Draw Circle (Xc, Yc, X, Y):
1. Call PutPixel(Xc + X, Yc, + Y)
2. Call PutPixel(Xc - X, Yc, + Y)
3. Call PutPixel(Xc + X, Yc, - Y)
4. Call PutPixel(Xc - X, Yc, - Y)
5. Call PutPixel(Xc + Y, Yc, + X)
6. Call PutPixel(Xc - Y, Yc, + X)
7. Call PutPixel(Xc + Y, Yc, - X)
8. Call PutPixel(Xc - Y, Yc, - X)
9. Exit


Esay To understand and learn this circle algorithm.If You got any error just fell free to comment bleow. Thanks aHappy learning. :)