1 / 17

Chapter 3: Windows, viewports

Chapter 3: Windows, viewports. World coordinates rather than screen coordinates. World “window” defines which part of world should be drawn, and which clipped away. Viewport defined in screen window mapping (scaling, shifting) between world window and viewport

cara
Download Presentation

Chapter 3: Windows, viewports

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Chapter 3: Windows, viewports • 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 CS Hons RW778 Graphics

  3. 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 CS Hons RW778 Graphics

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

  5. Chapter 3: Windows, viewports • 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 CS Hons RW778 Graphics

  6. Chapter 3: Windows, viewports • Chopping (no trivial accept/reject) • Goal : A.x, A.y? • A.x = W.right • A.y? • delx = P2.x – P1.x ; dely = P2.y – P1.y • e = P1.x – W.right ; d/dely = e/delx • Therefore P1.y = P1.y + (W.right – P1.x) * dely /delx CS Hons RW778 Graphics

  7. Chapter 3: Windows, viewports • 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 • 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. CS Hons RW778 Graphics

  8. 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| y(t) = H sin(t) |sin(t)2/n-1| • Also superhyperbola • 3.8.4 Polar Coordinate Shapes • x(t) = r(t) cos ((t)) • x(t) = r(t) cos ((t)) • Given point (r,  ), Cartesian point (x,y)is given by x = f () cos ()y = f () sin () CS Hons RW778 Graphics

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

  10. Chapter 4: Vector Tools Vector arithmetic allows to express geometric concepts algebraically. • 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 CS Hons RW778 Graphics

  11. Chapter 4: Vector Tools • 4.2.1 Operations with vectors • vector addition, scalar multiplication • 4.2.2 Linear combination of vectors • w = a1v1 + a2v2 + ... + amvm • Affine combination: a1+a2+...+am = 1 CS Hons RW778 Graphics

  12. Chapter 4: Vector Tools • Convex combination: a1+a2+...+am = 1 ai  0, for i = 1, ..., m • Set of all convex combinations of a vector v: v = (1-a) v1 + av2 , for 0  a  1 CS Hons RW778 Graphics

  13. Chapter 4: Vector Tools • 4.2.3 Magnitude of a vector; unit vectors • |w| is distance from head to tail, so that |w| = (w12+w22+...+wn2)0.5 • Scaling vector to unit length known as normalizing and obtain unit vector ŵ = (w/|w|) • 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 CS Hons RW778 Graphics

  14. Chapter 4: Vector Tools • 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 perpendicular – normal – orthogonal standard unit vectors CS Hons RW778 Graphics

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

  16. Chapter 4: Vector Tools 4.3.6 Applications of projection: Reflections Selfstudy. 4.4 The Cross Product of Two Vectors i j ka x b =ax ay az bx by bz • Examples; practice exercises: Selfstudy. CS Hons RW778 Graphics

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

More Related