Presentation is loading. Please wait.

Presentation is loading. Please wait.

OUTPUT PRIMITIVES / DISPLAY TECHNIQUES

Similar presentations


Presentation on theme: "OUTPUT PRIMITIVES / DISPLAY TECHNIQUES"— Presentation transcript:

1 OUTPUT PRIMITIVES / DISPLAY TECHNIQUES
LINE DRAWING TO DRAW LINE FROM (X1 Y1) TO (X2 Y2) (x2 y2) (x1y1)

2 RASTER SCREEN (x2 y2) (x1 y1)

3 DIGITAL DIFFERENTIAL ANALYZER (DDA)
y = m x + b m = (y2 - y1) / (x2 - x1) = y / x = dely / delx xk+1 = xk +  delx yk+1 = yk +  dely  = ?????

4 TWO ALTERNATIVES  = 1 / max [(x2-x1), (y2 - y1)] (BOOK)
 = 1 / 2 K WHERE K IS SUCH THAT 2K-1 < (max [(x2-x1), (y2 - y1)])  2K

5 SIMPLE DDA delx = x2 - x1; dely = y2 - y1; steps = abs(dely);
if abs (delx) > abs (dely) then steps = abs(delx); xinc = delx / steps; yinc = dely / steps; x = x1; y = y1; drawpixel (round(x), round(y)) for k = 1 to steps do begin x = x + xinc; y = y + yinc; end

6 BRESENHAM’S ALGO WHICH PIXEL NEXT ?? ? 2 (xk yk) ? 1

7 BRESENHAM’S ALGO (contd)
Deviations from the specified line path d1 = y - yk = m (xk + 1) + b - yk d2 = yk + 1 -y = yk m (xk + 1) - b d1 - d2 = 2 m (xk + 1) - 2yk + 2b -1 m = (y / x) pk = x (d1 - d2) = 2y . xk - 2x . yk + c

8 Pk = error at beginning of next pixel
If (at end of iteration k) true-line is below centre of pixel (pk < 0), draw pixel 1 else draw pixel 2 (in iteration k+1) 2 1

9 Brezenham’s algo (contd)
pk+1 - pk = 2 y (xk+1 -xk) - 2x (yk+1 -yk) = 2 y - 2x (yk+1 -yk) For pixel 1: = 2 y For pixel 2: = 2 y - 2x Hence if pk < 0, choose pixel 1 in iteration k+1, pk+1 = pk + 2 y else choose pixel 2 in iteration k+1, pk+1 = pk +2 y - 2 x Initial p0 = 2 y - x

10 Brezenham’s algo (contd)
pk + m - 1 pk + m pk = p0 = m - 0.5

11 Circle Generation (x - a)2 + (y - b)2 = r2
OR x = a + r cos ; y = b + r sin  (Fixed angular step size with lines between them) (Step Size = 1/r) OR m = dy / dx = - (x - a) / (y - b) USE DDA with m as above

12 MIDPOINT CIRCLE ALGO Next midpoint ?? 1 yk Yk - 1 ?? 2 xk xk + 1

13 MIDPOINT CIRCLE f (x, y) = x2 + y2 - r2
pk = (xk + 1)2 + (yk - 0.5)2 - r2 (error at next midpoint) If pk < 0 then Pixel 1 Else Pixel 2 (is closer to circle in iteration k+1) pk+1 = [(xk + 1) + 1]2 + (yk )2 - r2 pk+1 = pk + 2 (xk + 1) + (yk+12 - yk2) - (yk+1 -yk) + 1

14 MID POINT CIRCLE (contd)
Pk+1 - pk = 2 xk OR = 2 xk yk+1 p0 = 5/4 - r (PLEASE DERIVE) INITIAL POINT = (0, r) GET ONE POINT AND DUPLICATE IN 8 OCTANTS

15 ELLIPSE DRAWING SLOPE BASED (DDA) MIDPOINT ALGO
[(x - a) / rx]2 + [(y - b) / ry]2 = 1 f (x, y) = (x - a)2 ry2 + (y - b)2 rx2 -rx2 ry2 dy / dx = ???? If f(x, y) < 0, point is inside the ellipse

16 MIDPOINT ELLIPSE (contd)
Where slope < 1, xk+1 = xk + 1 Where slope > 1, yk+1 = yk - 1 pk = ???? Pk+1 - pk = ???? (For Regions 1 and 2)

17 OTHER CURVES FOR IMPLICIT CURVES F (X, Y) = 0, DEVELOP MIDPOINT ALGO (eg, hyperbola, parabola)

18 OTHER CURVES FOR EXPLICIT CURVES Y = F(X), OR PARAMETRIC CURVES - APPROXIMATE WITH STRAIGHT LINE SEGMENTS Generate points at constant parameter values Join them by straight lines Closer points for larger curvatures

19 ADDRESSING PIXELS BY PIXEL CENTERS
BY GRID OF PIXEL BOUNDARY LINES (H & V) PREFERRED, AS NO HALF INTEGER BOUNDARIES PRECISE OBJECT REPRESENTATIONS CONVENIENT IN RASTER ALGOS

20 SIZE OF OBJECTS RECTANGLE (0, 0) --- (4, 3) ? ? ? ? ? ? ? (4, 3)


Download ppt "OUTPUT PRIMITIVES / DISPLAY TECHNIQUES"

Similar presentations


Ads by Google