Math Primer for CG Ref: Interactive Computer Graphics, Chap. 4, E. Angel
Contents Scalar, Vector, Point Change of Basis Frame Change of Frame Affine Sum, Convex Combination, Convex Hull, … Case Study: shooting game
Introduction Three basic data types in CG: scalars, points, and vectors scalar: not a geometric type per se; used in measurement point: a location in space; exist regardless of any coordinate system vector: any quantity with direction and magnitude; does not have fixed location Examine these concepts in a mathematically more rigorous way …
Scalars: Live in Real Space Two fundamental operations are defined between pairs: Addition, multiplication Closure S, S, · S S Commutative · · Associative · · · · Distributive · · · Additive & multiplicative inverse ·
Real Analysis The study of real numbers … If you are interested, see Analysis WebNotes:Analysis WebNotes
Vectors: Live in Vector Space Two kinds of entities: Scalar, vector Two operations and corresponding geometric interpretations: v-v addition (head-tail) scalar-v multiplication (scaling of vector) Properties Closure u,v V, u+v V Commutative u+v=v+u Associative u+(v+w)=(u+v)+w Distributive (u+v)= u+ v )u= u+ u
Vector Space (cont) Linear combination u= 1 u 1 + 2 u 2 + … + n u n Linear independent Only set of scalars such that u= 1 u 1 + 2 u 2 + … + n u n is zero 1 = 2 =…= n =0 Basis a set of linearly independent vectors that span the space
Vector Space: change of basis represent any vector uniquely in a basis change of basis
Example New Basis
Points: Live in Affine Space Vector space lacks Location, distance, … Concept of coordinate system (frame) Reference point: origin Frame: origin + basis defines position in space Add another entity to vector spaces Point New operations Point – Point Vector Point + Vector Point (translation) Note that the following are not defined: point addition multiplication of scalar & point
Affine Space: change of frames Represent point in a frame Change of frame
Euclidean Space Supplement vector space with the notion of distance New operation Inner (dot) product S u,v,w V u · v=v · u ( u+ v) · w= u · w + v · w v · v>0 (v 0) 0 · 0=0 u · v=0 u and v are orthogonal |v|=(v · v) ½ u · v=|u||v| cos
Summary: Mathematical Spaces Real Space (Scalar) Vector Space (Scalar, Vector) Euclidean Space (Scalar, Vector) [distance] Affine Space (Scalar, Vector, Point) [location]
Affine Sum In affine space, point addition is only defined in the following case: Q R P( ) Point addition is allowed only if their weights add up to one
Affine Sum (cont) More generally, Convex Combination A particular affine sum where weights are non- negative
Convex Hull
Now, how to apply these math Besides change of basis/frame …
Ex: Parametric Equation of a Line Q R S( ) Q R
Ex: Plane, Triangle, Parallelogram Q R S( ) P T( ) (infinite) Plane Parallelogram Triangle
Ex: Homogeneous Coordinates A unified representation scheme in affine space for points and vectors Change of Frame: subsume change of basis
Affine Space: coordinate system fixing the origin of the vectors of coordinate system at P 0 4x1 “ vector ” : Unified vector & point representation homogeneous coordinate distinguish point & vector 4x4 matrix algebra for change in frames Point: [ 1 2 3 1] Frame: [u 1 u 2 u 3 P 0 ] Vector: [ 1 2 3 0] Frame: [u 1 u 2 u 3 P 0 ]
Ex: Shooting (AABB) Intersection can be checked using 3D Sutherland algorithm
Cohen-Sutherland Line-Clipping Algorithm Trivially accept Trivially reject clipping
Ex: Shooting (OBB) Change of frame then apply Sutherland algorithm in the local frame
Ex: Ray-Triangle Intersection
Ex: Shooting (discrete version)
Ex: Shooting (continuous version)
Exercise Convex Hull: prove convex combination yields the shape you imagine