Presentation is loading. Please wait.

Presentation is loading. Please wait.

2003CS Hons RW778 Graphics1 Chapter 3: Windows, viewports World coordinates rather than screen coordinates. World coordinates rather than screen coordinates.

Similar presentations


Presentation on theme: "2003CS Hons RW778 Graphics1 Chapter 3: Windows, viewports World coordinates rather than screen coordinates. World coordinates rather than screen coordinates."— Presentation transcript:

1 2003CS Hons RW778 Graphics1 Chapter 3: Windows, viewports World coordinates rather than screen coordinates. World coordinates rather than screen coordinates. World “window” defines which part of world should be drawn, and which clipped away. World “window” defines which part of world should be drawn, and which clipped away. Viewport defined in screen window Viewport defined in screen window –mapping (scaling, shifting) between world window and viewport –draw in world window; automatically mapped to viewport

2 2003CS Hons RW778 Graphics2 Chapter 3: Windows, viewports 3.2.1 Window to viewport mapping 3.2.1 Window to viewport mapping –W, V: rectangles: left, right, top, bottom –May have different ratios: distortion –A, B scale; C, D translate

3 2003CS Hons RW778 Graphics3 Chapter 3: Windows, viewports –Read: Example 3.2.1, exercise 3.2.1, example 3.2.2 –Selfstudy: »Ex. 3.2.3 Drawing polylines from a file »Ex. 3.2.4 Tiling a window with a motif »Ex. 3.2.5 Clipping, zooming and roaming »p. 91: smooth animations and double buffering »Ex. 3.2.2 Whirling swirls

4 2003CS Hons RW778 Graphics4 Chapter 3: Windows, viewports 3.2.2 Setting Window and Viewport automatically 3.2.2 Setting Window and Viewport automatically –Selfstudy. 3.3 Clipping lines 3.3 Clipping lines –OpenGL automatically; algorithms

5 2003CS Hons RW778 Graphics5 Chapter 3: Windows, viewports 3.3.2 Cohen-Sutherland clipping 3.3.2 Cohen-Sutherland clipping –Checks for trivial accept or trivial reject »Inside-outside code word for each endpoint »Trivial accept: Both code words are FFFF »Trivial reject: Code words have T in same position

6 2003CS Hons RW778 Graphics6 Chapter 3: Windows, viewports –Chopping (no trivial accept/reject) »Goal : A.x, A.y? »A.x = W.right »A.y? delx = P 2.x – P 1.x ; dely = P 2.y – P 1.y delx = P 2.x – P 1.x ; dely = P 2.y – P 1.y e = P 1.x – W.right ; d/dely = e/delx e = P 1.x – W.right ; d/dely = e/delx Therefore P 1.y = P 1.y + (W.right – P 1.x) * dely /delx Therefore P 1.y = P 1.y + (W.right – P 1.x) * dely /delx

7 2003CS Hons RW778 Graphics7 Chapter 3: Windows, viewports The Canvas Class: Selfstudy. The Canvas Class: Selfstudy. –3.4 Developing the canvas class –3.5 Relative drawing –3.6 Figures based on regular polygons –3.7 Drawing circles and arcs 3.8 Parametric forms of curves 3.8 Parametric forms of curves –Implicit : Point on line if F(x,y) = 0 (inside-outside form) –Parametric: Position at time t is given by x(t), y(t) –Finding implicit form for parametric form –NB! Practice exercises p. 122-123 : selfstudy –Drawing parametric curves: Trivial.

8 2003CS Hons RW778 Graphics8 Chapter 3: Windows, viewports –3.8.3 Super-ellipses »Implicit : (x/W) n + (y/H) n =1 »Parametric: x(t) = W cos(t) |cos(t) 2/n-1 | x(t) = W cos(t) |cos(t) 2/n-1 | y(t) = H sin(t) |sin(t) 2/n-1 | y(t) = H sin(t) |sin(t) 2/n-1 | »Also superhyperbola –3.8.4 Polar Coordinate Shapes »x(t) = r(t) cos (  (t)) »Given point (r,  ), Cartesian point (x,y) is given by x = f (  ) cos (  ) y = f (  ) sin (  )

9 2003CS Hons RW778 Graphics9 Chapter 3: Windows, viewports »Note conic sections, logarithmic spiral –3.8.5 3D Curves »Helix, toroidal spiral Read Case Studies pp. 130 – 142 Read Case Studies pp. 130 – 142

10 2003CS Hons RW778 Graphics10 Chapter 4: Vector Tools Vector arithmetic allows to express geometric concepts algebraically. 4.2 Review of vectors 4.2 Review of vectors –Vector is object with length and direction –Think of vector as displacement –The difference between two points is a vector: v = Q-P

11 2003CS Hons RW778 Graphics11 Chapter 4: Vector Tools 4.2.1 Operations with vectors 4.2.1 Operations with vectors –vector addition, scalar multiplication 4.2.2 Linear combination of vectors 4.2.2 Linear combination of vectors –w = a 1 v 1 + a 2 v 2 +... + a m v m –Affine combination: a 1 +a 2 +...+a m = 1

12 2003CS Hons RW778 Graphics12 Chapter 4: Vector Tools –Convex combination: a 1 +a 2 +...+a m = 1 a i  0, for i = 1,..., m –Set of all convex combinations of a vector v: v = (1-a) v 1 + av 2, for 0  a  1

13 2003CS Hons RW778 Graphics13 Chapter 4: Vector Tools 4.2.3 Magnitude of a vector; unit vectors 4.2.3 Magnitude of a vector; unit vectors –|w| is distance from head to tail, so that |w| = (w 1 2 +w 2 2 +...+w n 2 ) 0.5 –Scaling vector to unit length known as normalizing and obtain unit vector ŵ = (w/|w|) 4.3 Dot product 4.3 Dot product –d = v. w = –Properties: »a. b = b. a »(a+c). b = a. b + c. b »(sa). b = s (a. b) »|b| 2 = b. b

14 2003CS Hons RW778 Graphics14 Chapter 4: Vector Tools 4.3.2 Angle between two vectors 4.3.2 Angle between two vectors –cos (θ) = (b/|b|).(c/|c|) The cosine between two vectors is the dot product of the normalized vectors. 4.3.3 The sign of b.c, and perpendicularity 4.3.3 The sign of b.c, and perpendicularity perpendicular – normal – orthogonal standard unit vectors

15 2003CS Hons RW778 Graphics15 Chapter 4: Vector Tools 4.3.4 The 2D Perp Vector 4.3.4 The 2D Perp Vector –Let a=(a x,a y ). Then a  = (-a y,a x ) is the counterclockwise perpendicular to a (the perp). –Selfstudy: Practice exercises p. 157. 4.3.5 Orthogonal projections and distances 4.3.5 Orthogonal projections and distances –How far? Where? Decompose?

16 2003CS Hons RW778 Graphics16 Chapter 4: Vector Tools 4.3.6 Applications of projection: Reflections Selfstudy. 4.4 The Cross Product of Two Vectors i j k a x b = a x a y a z b x b y b z i j k a x b = a x a y a z b x b y b z –Examples; practice exercises: Selfstudy.

17 2003CS Hons RW778 Graphics17 Chapter 3: Windows, Viewports Programming Task 2 : Implement Case Study 3.6.1 (Basic tilings), p. 138, in Hill. Programming Task 2 : Implement Case Study 3.6.1 (Basic tilings), p. 138, in Hill.


Download ppt "2003CS Hons RW778 Graphics1 Chapter 3: Windows, viewports World coordinates rather than screen coordinates. World coordinates rather than screen coordinates."

Similar presentations


Ads by Google