1
Prof. RATNADEEPSINH M. JADEJA
Assistant Professor
Mechanical Department
CHAPTER 2.2: INTERACTIVE COMPUTER GRAPHICS
Mechanical Engineering Department – School Of Engineering
RANDOM SCAN SYSTEM
2
In Random Scan System, an electron beam is
directed to only those parts of the screen where a
picture is to be drawn. The picture is drawn one
line at a time, so also called vector displays or
stroke writing displays. After drawing the picture
the system cycles back to the first line and design
all the lines of the picture 30 to 60 time each
second.
Mechanical Engineering Department – School Of Engineering
RASTER SCAN SYSTEM
3
It is the most common type of graphics monitor based on television technology. In a raster
scan system, the electron beam is swept across the screen, one row at a time from top to
bottom. When electron beam moves across each row the beam intensity is turned ON and
OFF to create a pattern of illuminated spots. Picture definition is stored in a memory called
frame buffer which holds the set of intensity values, which are then retrieved from the frame
buffer and pointed on the screen one row at a time as shown in figure below:
Mechanical Engineering Department – School Of Engineering
REPRESENTATION OF LINE AND CIRCLE
4
Mechanical Engineering Department – School Of Engineering
DDA ALGORITHM
5
(Xn, Yn)
(X1, Y1)
ΔX
ΔY
XK XK+1
YK
YK+1
X
Y
Y = MX + C
= =
ΔY
ΔX
= =
ΔY = ΔX ΔX = ΔY
YK+1 = YK + ΔY
XK+1 = XK + ΔX
Similarly
Mechanical Engineering Department – School Of Engineering
DDA ALGORITHM
6
CASE 1 = − 1 > − 1
ΔX = +1 if Xn > X1
ΔX = -1 if Xn < X1
∶
ΔY = ΔX
YK+1 = YK + ΔY
XK+1 = XK + ΔX
CASE 2 = − 1 > − 1
ΔY = +1 if Yn > Y1
ΔY = -1 if Yn < Y1
∶
ΔX = ΔY
YK+1 = YK + ΔY
XK+1 = XK + ΔX
Mechanical Engineering Department – School Of Engineering
EXAMPLE
7
EXAMPLE 1: Generate a straight line connecting two points (1, 2) and (8, 6) using DDA algorithm.
X1 = 1
Xn = 8
Y1 = 2
Yn = 6
Estimation of increments
Xn – X1 = 8 – 1 = 7
Yn – Y1 = 6 – 2 = 4
− 1 > − 1
and Xn > X1
So, ΔX = 1
and
ΔY = ΔX = = 0.571
Mechanical Engineering Department – School Of Engineering
EXAMPLE cont..
8
POINT 1
X1 = X1+ 0.5 = 1 + 0.5 = 1.5
Y1 = Y1+ 0.5 = 2 + 0.5 = 2.5
POINT 2
X2 = X1+ ΔX = 1.5 + 1 = 2.5
Y2 = Y1+ ΔY = 2.5 + 0.571 = 3.071
POINT 3
X3 = X2+ ΔX = 2.5 + 1 = 3.5
Y3 = Y2+ ΔY = 3.071 + 0.571 = 3.642
POINT 4
X4 = X3+ ΔX = 3.5 + 1 = 4.5
Y4 = Y3+ ΔY = 3.642 + 0.571 = 4.213
POINT 5
X5 = X4+ ΔX = 4.5 + 1 = 5.5
Y5 = Y4+ ΔY = 4.213 + 0.571 = 4.784
POINT 6
X6 = X5+ ΔX = 5.5 + 1 = 6.5
Y6 = Y5+ ΔY = 4.784 + 0.571 = 5.355
POINT 7
X7 = X6+ ΔX = 6.5 + 1 = 7.5
Y7 = Y6+ ΔY = 5.355 + 0.571 = 5.926
POINT 8
X8 = X7+ ΔX = 7.5 + 1 = 8.5
Y8 = Y7+ ΔY = 5.926 + 0.571 = 6.497
(X6, Y6) = (6, 5)
(X2, Y2) = (2, 3)
(X3, Y3) = (3, 3)
(X4, Y4) = (4, 4)
(X5, Y5) = (5, 4)
(X8, Y8) = (8, 6)
(X1, Y1) = (1, 2)
(X7, Y7) = (7, 5)
Mechanical Engineering Department – School Of Engineering
BRESENHAM’S ALGORITHM
9
1. Input the two end points (X1, Y1) and (Xn, Yn).
2. Calculate : Xc = Xn – X1 and Yc = Yn – Y1
If Xc > Yc then slop is less then 1 so, ΔX = 1
3. Calculate the starting value of decision parameter P1 as P1 = 2Yc – Xc
4. If Pk < 0 The next point is (Xk+1, Yk) and Pk+1 = Pk + 2Yc
If Pk > 0 The next point is (Xk+1, Yk+1) and Pk+1 = Pk + 2Yc – 2Xc
Mechanical Engineering Department – School Of Engineering
EXAMPLE
10
Example 2: Generate a straight line connecting two end points (21, 11) and (26, 15) using
Bresenham’s algorithm.
Solution:
X1 = 21 Y1 = 11
X2 = 26 Y2 = 15
Xc = Xn – X1 = 26 – 21 = 5
Yc = Yn – Y1 = 15 – 11 = 4 (Xc > Yc, so slop is less then 1 so, ΔX = 1)
Point 1:
(x1, y1) = (21, 11)
P1 = 2Yc – Xc = 8 – 5 = 3 (P > 0)
Point 2:
X2 = x1 + Δx = 21 + 1 = 22
Y2 = Y1 + Δy = 11 + 1 = 12 (x2, y2) = (22, 12)
P2 = P1 + 2Yc – 2Xc = 3 + 8 – 10 = 1 (P > 0)
Mechanical Engineering Department – School Of Engineering
EXAMPLE cont..
11
Point 3:
X3 = x2 + Δx = 22 + 1 = 23
Y3 = Y2 + Δy = 12 + 1 = 13 (x3, y3) = (23, 13)
P3 = P2 + 2Yc – 2Xc = 1 + 8 – 10 = -1 (P < 0)
Point 4:
X4 = x3 + Δx = 23 + 1 = 24
Y4 = Y3 = 13 (x4, y4) = (24, 13)
P4 = P3 + 2Yc = -1 + 8 = 7 (P > 0)
Point 5:
X5 = x4 + Δx = 24 + 1 = 25
Y5 = Y4 + Δy = 13 + 1 = 14 (x4, y4) = (25, 14)
P5 = P4 + 2Yc – 2Xc = 7 + 8 – 10 = 5 (P > 0)
Point 6:
X6 = x5 + Δx = 25 + 1 = 26
Y6 = Y5 + Δy = 14 + 1 = 15 (x4, y4) = (26, 15)
P6 = P5 + 2Yc – 2Xc = 5 + 8 – 10 = 3 (P > 0)

2.2. interactive computer graphics

  • 1.
    1 Prof. RATNADEEPSINH M.JADEJA Assistant Professor Mechanical Department CHAPTER 2.2: INTERACTIVE COMPUTER GRAPHICS
  • 2.
    Mechanical Engineering Department– School Of Engineering RANDOM SCAN SYSTEM 2 In Random Scan System, an electron beam is directed to only those parts of the screen where a picture is to be drawn. The picture is drawn one line at a time, so also called vector displays or stroke writing displays. After drawing the picture the system cycles back to the first line and design all the lines of the picture 30 to 60 time each second.
  • 3.
    Mechanical Engineering Department– School Of Engineering RASTER SCAN SYSTEM 3 It is the most common type of graphics monitor based on television technology. In a raster scan system, the electron beam is swept across the screen, one row at a time from top to bottom. When electron beam moves across each row the beam intensity is turned ON and OFF to create a pattern of illuminated spots. Picture definition is stored in a memory called frame buffer which holds the set of intensity values, which are then retrieved from the frame buffer and pointed on the screen one row at a time as shown in figure below:
  • 4.
    Mechanical Engineering Department– School Of Engineering REPRESENTATION OF LINE AND CIRCLE 4
  • 5.
    Mechanical Engineering Department– School Of Engineering DDA ALGORITHM 5 (Xn, Yn) (X1, Y1) ΔX ΔY XK XK+1 YK YK+1 X Y Y = MX + C = = ΔY ΔX = = ΔY = ΔX ΔX = ΔY YK+1 = YK + ΔY XK+1 = XK + ΔX Similarly
  • 6.
    Mechanical Engineering Department– School Of Engineering DDA ALGORITHM 6 CASE 1 = − 1 > − 1 ΔX = +1 if Xn > X1 ΔX = -1 if Xn < X1 ∶ ΔY = ΔX YK+1 = YK + ΔY XK+1 = XK + ΔX CASE 2 = − 1 > − 1 ΔY = +1 if Yn > Y1 ΔY = -1 if Yn < Y1 ∶ ΔX = ΔY YK+1 = YK + ΔY XK+1 = XK + ΔX
  • 7.
    Mechanical Engineering Department– School Of Engineering EXAMPLE 7 EXAMPLE 1: Generate a straight line connecting two points (1, 2) and (8, 6) using DDA algorithm. X1 = 1 Xn = 8 Y1 = 2 Yn = 6 Estimation of increments Xn – X1 = 8 – 1 = 7 Yn – Y1 = 6 – 2 = 4 − 1 > − 1 and Xn > X1 So, ΔX = 1 and ΔY = ΔX = = 0.571
  • 8.
    Mechanical Engineering Department– School Of Engineering EXAMPLE cont.. 8 POINT 1 X1 = X1+ 0.5 = 1 + 0.5 = 1.5 Y1 = Y1+ 0.5 = 2 + 0.5 = 2.5 POINT 2 X2 = X1+ ΔX = 1.5 + 1 = 2.5 Y2 = Y1+ ΔY = 2.5 + 0.571 = 3.071 POINT 3 X3 = X2+ ΔX = 2.5 + 1 = 3.5 Y3 = Y2+ ΔY = 3.071 + 0.571 = 3.642 POINT 4 X4 = X3+ ΔX = 3.5 + 1 = 4.5 Y4 = Y3+ ΔY = 3.642 + 0.571 = 4.213 POINT 5 X5 = X4+ ΔX = 4.5 + 1 = 5.5 Y5 = Y4+ ΔY = 4.213 + 0.571 = 4.784 POINT 6 X6 = X5+ ΔX = 5.5 + 1 = 6.5 Y6 = Y5+ ΔY = 4.784 + 0.571 = 5.355 POINT 7 X7 = X6+ ΔX = 6.5 + 1 = 7.5 Y7 = Y6+ ΔY = 5.355 + 0.571 = 5.926 POINT 8 X8 = X7+ ΔX = 7.5 + 1 = 8.5 Y8 = Y7+ ΔY = 5.926 + 0.571 = 6.497 (X6, Y6) = (6, 5) (X2, Y2) = (2, 3) (X3, Y3) = (3, 3) (X4, Y4) = (4, 4) (X5, Y5) = (5, 4) (X8, Y8) = (8, 6) (X1, Y1) = (1, 2) (X7, Y7) = (7, 5)
  • 9.
    Mechanical Engineering Department– School Of Engineering BRESENHAM’S ALGORITHM 9 1. Input the two end points (X1, Y1) and (Xn, Yn). 2. Calculate : Xc = Xn – X1 and Yc = Yn – Y1 If Xc > Yc then slop is less then 1 so, ΔX = 1 3. Calculate the starting value of decision parameter P1 as P1 = 2Yc – Xc 4. If Pk < 0 The next point is (Xk+1, Yk) and Pk+1 = Pk + 2Yc If Pk > 0 The next point is (Xk+1, Yk+1) and Pk+1 = Pk + 2Yc – 2Xc
  • 10.
    Mechanical Engineering Department– School Of Engineering EXAMPLE 10 Example 2: Generate a straight line connecting two end points (21, 11) and (26, 15) using Bresenham’s algorithm. Solution: X1 = 21 Y1 = 11 X2 = 26 Y2 = 15 Xc = Xn – X1 = 26 – 21 = 5 Yc = Yn – Y1 = 15 – 11 = 4 (Xc > Yc, so slop is less then 1 so, ΔX = 1) Point 1: (x1, y1) = (21, 11) P1 = 2Yc – Xc = 8 – 5 = 3 (P > 0) Point 2: X2 = x1 + Δx = 21 + 1 = 22 Y2 = Y1 + Δy = 11 + 1 = 12 (x2, y2) = (22, 12) P2 = P1 + 2Yc – 2Xc = 3 + 8 – 10 = 1 (P > 0)
  • 11.
    Mechanical Engineering Department– School Of Engineering EXAMPLE cont.. 11 Point 3: X3 = x2 + Δx = 22 + 1 = 23 Y3 = Y2 + Δy = 12 + 1 = 13 (x3, y3) = (23, 13) P3 = P2 + 2Yc – 2Xc = 1 + 8 – 10 = -1 (P < 0) Point 4: X4 = x3 + Δx = 23 + 1 = 24 Y4 = Y3 = 13 (x4, y4) = (24, 13) P4 = P3 + 2Yc = -1 + 8 = 7 (P > 0) Point 5: X5 = x4 + Δx = 24 + 1 = 25 Y5 = Y4 + Δy = 13 + 1 = 14 (x4, y4) = (25, 14) P5 = P4 + 2Yc – 2Xc = 7 + 8 – 10 = 5 (P > 0) Point 6: X6 = x5 + Δx = 25 + 1 = 26 Y6 = Y5 + Δy = 14 + 1 = 15 (x4, y4) = (26, 15) P6 = P5 + 2Yc – 2Xc = 5 + 8 – 10 = 3 (P > 0)