
Geometry CS148, Summer 2010 Siddhartha Chaudhuri 1 Ödegaard and Wennergren, 2D projections of 4D “Julia sets” 2 Addition of Vectors ● “Parallelogram Rule” ̂ u u + v v ● u + (-v) ≡ u - v 4 Dot Product Orthogonal and Orthonormal Vectors ● ● Orthogonal vectors are at right angles to each If θ is the angle between u u and v, then other ● u‧v = 0 θ u‧v = ║u║║v║cos θ v ● Orthonormal vectors are at right angles to each other and each has unit length ║u║cos θ ● A set {ui} of orthonormal vectors has ● u ‧u = 1 if i = j ● This is also the length of the orthogonal projection i j ● of u onto v, times the length of v ui‧uj = 0 if i ≠ j ● Note: u‧u = ║u║2 5 6 Cross Product (only 3D) Position Vector ● If θ is the angle between u and v, then ● Identifies point in space u × v = (║u║║v║sin θ) ŵ ● Interpreted as: tip of vector “arrow” when the other end is placed at a fixed point called the origin of the ● ŵ is a unit vector orthogonal to both u and v space ● “Right-Hand Rule”: – Curl fingers of right hand from u to v ŵ y – Thumb points in direction of ŵ Position u θ x v Origin Area of parallelogram = ║u × v║ 7 8 Vectors: the “Physical” View Cartesian/Euclidean n-space ℝn ● Directions and positions are different! ● Vectors represented by real n‑tuples of coordinates ● “Legal” Operations: (u1, u2, ..., un) ● Direction = Scalar * Direction – 2D: (x, y) u ● Direction = Direction + Direction – 3D: (x, y, z) ● Position = Position + Direction y ● Represents extent along ● Direction = Position – Position orthogonal coordinate axes ● “Illegal” Operations: – Right-handed system: Curl right hand fingers from x axis to x ● Position = Scalar * Position y axis, thumb points along z axis ● 2 2 2 ½ Position = Position + Position ● Length/magnitude:║u║ = (u1 + u2 + … + un ) ● Direction = Position + Direction – From Pythagoras' Theorem ● Position = Position - Position 9 10 Cartesian/Euclidean n-space ℝn Cartesian/Euclidean n-space ℝn ● ● Dot Product: Let u = (u1, u2, ..., un) and v = (v1, v2, ..., vn) ● Addition of vectors: u‧v ≡ (u1v1 + u2v2 + … + unvn) u + v ≡ (u1 + v1, u2 + v2, ..., un + vn) ● Cross Product (remember, 3D only!): ● Multiplication of vector by scalar: u × v ≡ (u2v3 – u3v2, u3v1 – u1v3, u1v2 - u2v1) su ≡ (su1, su2, ..., sun) 11 12 Another Way to Remember the Cross Vectors: the “Mathematical” View Product in ℝ3 ● Vector space: Set of objects (vectors) closed under ● Addition of two vectors ● ● Multiplication of a vector by a scalar (from field ) Let u = (x1, y1, z1) and v = (x2, y2, z2) F ● Necessary properties of vector spaces ● u × v ≡ (y1z2 – z1y2, z1x2 – x1z2, x1y2 - y1x2) ● Commutative addition: x + y = y + x If u and v are 2D instead, this is the ● Associative addition: (x + y) + z = x + (y + z) area of the parallelogram between them ● Existence of additive identity 0: x + 0 = 0 + x – Can show: 0.x = 0 (prove!) ● Existence of additive inverse -x: x + (-x) = 0 13 – Can show: -x = -1.x (prove!) 14 Vectors: the “Mathematical” View Basis and Dimension ● Properties of vector spaces (contd.) ● Linear combination of vectors {ui}: ∑ciui ● Associative scalar multiplication: r(sx) = (rs)x ● {ci}: Scalar coefficients ● Distributive scalar sum: (r + s)x = rx + sx ● {ui} is linearly independent if no ui can be ● Distributive scalar multiplication: r(x + y) = rx + ry expressed as a linear combination of the others ● Scalar multiplication identity: 1.x = x ● Span of {u }: Set of all linear combinations – Note: This says that the identity for multiplication of two i scalars is also the identity for multiplication of a vector by a scalar ● Basis of vector space: Set of linearly independent vectors whose span is the entire space ● Dimension of vector space: Cardinality of basis ● 15 Note: All bases have same cardinality 16 Basis ● ̂ ̂ ̂ Let a vector space have basis B = [u1, u2, ..., un] ● ̂ Any vector u can be written as ∑i = 1...n uiui ̂ ● Or compactly, (u1, u2, ..., un) ● These are the coordinates of u in basis B ̂ ● Note: ̂ ● We've generalized our original notion of coordinates: they're now relative to the selected basis (axes) ● A point has different coordinates in different bases 17 Change of Basis (example in 3D) Change of Basis (example in 3D) ● Let [u, v, n] be a basis B for a vector space ● Let coordinates of u, v, n in another basis B0 be u = (u1, u2, u3) 0 a1 u1 v1 n1 a1 v = (v1, v2, v3) 0 a2 = u2 v2 n2 a2 n = (n1, n2, n3) 0 a u3 v3 n3 a3 [ 3] [ ] [ ] ● Let coordinates of a in B be (a1, a2, a3) 0 0 0 ● Let coordinates of a in B0 be (a 1, a 2, a 3) 19 20 Change of Basis (example in 3D) Metric ● ● If B and B0 are orthonormal, inverse of matrix is Assign non-negative real number d(u, v) to every its transpose (orthogonal matrix) pair of vectors u, v ● Interpret as distance between u and v 0 a1 u1 u2 u3 a1 ● Necessary properties of metric 0 a2 = v1 v2 v3 a2 ● d(u, v) ≥ 0 0 a3 n1 n2 n3 a ● [ ] [ ] [ 3 ] d(u, v) = 0 if and only if u = v (only if bases are orthonormal) ● d(u, v) = d(v, u) ● d(u, v) ≤ d(u, w) + d(w, v) (Triangle Inequality) 21 22 ℝn as Metric Space Inner Product 2 2 2 ½ ● ● Magnitude: L2 norm:║u║ = (u1 + u2 + … + un ) Assign scalar 〈u, v〉 ∈ F to pair of vectors u, v ● F is assumed to be set of real or complex numbers ● Metric d(u, v) defined as ║u - v║ ● Necessary properties of inner product ● ● 〈u, v〉 = 〈v, u〉 (overline denotes complex conjugate) Other common magnitude functions: Lp norms ● 〈su, v〉 = s〈u, v〉 ║u║ = (⎢u ⎢p + ⎢u ⎢p + … + ⎢u ⎢p)1/p 1 2 n ● 〈u + v, w〉 = 〈u, w〉 + 〈v, w〉 ● L1 is “Manhattan” norm ● The dot product is a valid inner product for ℝn ● L∞ is “max” norm 23 24 Transformations of Vectors Translation (Thanks to Pat Hanrahan for this section) ● u' = T(u) ● Why? ● Modeling: – Create objects in convenient coordinates – Multiple instances of prototype shape – Kinematics of linked structures ● Viewing: – Map between window and device coordinates – Virtual camera projections: parallel/perspective ● We'll stick to ℝ2 for now 25 26 Scaling Rotation Uniform Non-uniform (counter-clockwise about origin) 27 28 Reflection Shear 29 30 Composing Transformations Composing Transformations R(45) T(1, 1) R(45) T(1, 1) R(45) T(1, 1) Rotate, then Translate Translate, then Rotate 31 32 Order Matters! World Space and Object Space ● Transformation maps from one to the other ● Construct by composing sequence Object (Local) Space of basic transforms ● Remember: Transforms apply Right‑to‑Left in our notation! World (Global) Space T(1, 1) R(45) ≠ R(45) T(1, 1) 33 34 World Space and Object Space Translation ● Let's look at the example on the right ● Object → World: Object (Local) Space ● Rotate by (ccw), then θ θ translate by t ● World → Object: t ● Translate by -t, then World (Global) Space rotate by -θ x' = x + tx y' = y + ty Make sure you understand this! 35 36 Scaling (and Reflection) CCW Rotation By θ About Origin x' = s x (Negative scaling x' = x cos θ - y sin θ x coefficients give y' = x sin θ + y cos θ y' = sy y reflection) 37 38 Horizontal Shear Vertical Shear x' = x + sy x' = x y' = y y' = sx + y 39 40 Types of 2D Transformations Homogenous Coordinates (2D) ● Linear Transforms: T(u + v) = T(u) + T(v) ● Point (x, y) → (x, y, 1) ● Scaling ● Direction (x, y) → (x, y, 0) ● Rotation ● For any scalar c, (cx, cy, ch) ≡ (x, y, h) ● Shear ● To convert back: ● Reflection ● If h is 0: (x, y, 0) → (x, y) ● Affine Transforms: T(u) = L(u) + a, where L is linear and a is a fixed vector ● If h is non-zero: (x, y, h) → (x / h, y / h) ● ● Translation Note: ● ● Other, e.g. perspective projection Not 3D vector space, just a new representation for 2D ● Legal/illegal operations for directions & positions ● How do we represent these in a common format? 41 automatically distinguished! 42 Translation Scaling (and Reflection) 1 0 t s 0 0 x' = x + t x ' x x x ' x x x x' = sx x y ' = 0 1 t y y y ' = 0 s y 0 y y' = y + t y' = s y y [ 1 ] 0 0 1 [ 1] y [ 1 ] 0 0 1 [1] [ ] 43 [ ] 44 CCW Rotation By θ About Origin Horizontal Shear x ' cos −sin 0 x x ' 1 s 0 x x' = x + sy x' = x cos θ - y sin θ y ' = sin cos 0 y y ' = 0 1 0 y y' = y y' = x sin θ + y cos θ [ 1 ] 0 0 1 [1] [ 1 ] [0 0 1] [1] [ ] 45 46 Vertical Shear What about 3D? ● Very similar: (x, y, z) → (x, y, z, h) ● Look up the formulæ! ● Rotation is a mess ● Common method: – Map axis of rotation to a coordinate axis (similar to change of basis) – Rotate around the coordinate axis – Map back x ' 1 0 0 x x' = x ● Other approaches based on Euler angles and y ' = s 1 0 y quaternions y' = sx + y [ 1 ] [0 0 1] [1] 47 48 Why Use Matrices? Hierarchical Modeling ● Graphics systems maintain a current ● Compute the matrix once transformation matrix (CTM) x' = x cos θ - y sin θ ● All geometry is transformed by the CTM y' = x sin θ + y cos θ ● CTM defines object space in which geometry is specified ● Don't repeatedly evaluate sines and cosines ● Transformation commands are concatenated onto the CTM.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages9 Page
-
File Size-