OUTPUT%20PRIMITIVES%20/%20DISPLAY%20TECHNIQUES - PowerPoint PPT Presentation

About This Presentation
Title:

OUTPUT%20PRIMITIVES%20/%20DISPLAY%20TECHNIQUES

Description:

pk = (xk 1)2 (yk - 0.5)2 - r2 (error at next midpoint) ... CONVENIENT IN RASTER ALGOS. SIZE OF OBJECTS. RECTANGLE (0, 0) --- (4, 3) (0, 0) (4, 3) ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 21
Provided by: acha68
Learn more at: http://mgarland.org
Category:

less

Transcript and Presenter's Notes

Title: OUTPUT%20PRIMITIVES%20/%20DISPLAY%20TECHNIQUES


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
  • xk1 xk ? delxyk1 yk ? dely
  • ? ?????

4
TWO ALTERNATIVES
  • ? 1 / max (x2-x1), (y2 - y1) (BOOK)
  • ? 1 / 2 K WHERE K IS SUCH THAT2K-1 lt (max
    (x2-x1), (y2 - y1)) ? 2K

5
SIMPLE DDA
  • delx x2 - x1 dely y2 - y1 steps
    abs(dely)
  • if abs (delx) gt 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
  • drawpixel (round(x), round(y))
  • end
  • end

6
BRESENHAMS ALGO
  • WHICH PIXEL NEXT ??

? 2
(xk yk)
? 1
7
BRESENHAMS ALGO (contd)
  • Deviations from the specified line path
  • d1 y - yk m (xk 1) b - yk
  • d2 yk 1 -y yk 1 - 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 lt 0), draw pixel 1 else draw
pixel 2 (in iteration k1)
2
1
9
Brezenhams algo (contd)
  • pk1 - pk 2 ?y (xk1 -xk) - 2?x (yk1 -yk) 2
    ?y - 2?x (yk1 -yk)
  • For pixel 1 2 ?y
  • For pixel 2 2 ?y - 2?x
  • Hence if pk lt 0, choose pixel 1 in iteration k1,
    pk1 pk 2 ?y
  • else choose pixel 2 in iteration k1, pk1 pk
    2 ?y - 2 ?x
  • Initial p0 2 ?y - ?x

10
Brezenhams 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 lt 0 then Pixel 1 Else Pixel 2 (is closer to
    circle in iteration k1)
  • pk1 (xk 1) 12 (yk1 - 0.5)2 - r2
  • pk1 pk 2 (xk 1) (yk12 - yk2) - (yk1
    -yk) 1

14
MID POINT CIRCLE (contd)
  • Pk1 - pk 2 xk1 1 OR 2 xk1 1 - 2yk1
  • 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) / rx2 (y - b) / ry2 1
  • f (x, y) (x - a)2 ry2 (y - b)2 rx2 -rx2 ry2
  • dy / dx ????
  • If f(x, y) lt 0, point is inside the ellipse

16
MIDPOINT ELLIPSE (contd)
  • Where slope lt 1, xk1 xk 1
  • Where slope gt 1, yk1 yk - 1
  • pk ????
  • Pk1 - 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)
?
?
?
(0, 0)
Write a Comment
User Comments (0)
About PowerShow.com