Title: Chapter 3: Windows, viewports
1Chapter 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
2Chapter 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
3Chapter 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
4Chapter 3 Windows, viewports
- 3.2.2 Setting Window and Viewport automatically
- Selfstudy.
- 3.3 Clipping lines
- OpenGL automatically algorithms
5Chapter 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
6Chapter 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
7Chapter 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.
8Chapter 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 (?)
9Chapter 3 Windows, viewports
- Note conic sections, logarithmic spiral
- 3.8.5 3D Curves
- Helix, toroidal spiral
- Read Case Studies pp. 130 142
10Chapter 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
11Chapter 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 a1a2...am 1
12Chapter 4 Vector Tools
- Convex combination
- a1a2...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
13Chapter 4 Vector Tools
- 4.2.3 Magnitude of a vector unit vectors
- w is distance from head to tail, so that w
(w12w22...wn2)0.5 - Scaling vector to unit length known as
normalizing and obtain unit vector w (w/w) - 4.3 Dot product
- d v . w
- Properties
- a . b b . a
- (ac) . b a . b c . b
- (sa) . b s (a . b)
- b2 b . b
14Chapter 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
15Chapter 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?
16Chapter 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.
17Chapter 3 Windows, Viewports
- Programming Task 2 Implement Case Study 3.6.1
(Basic tilings), p. 138, in Hill.