Title: Math Primer for CG
1Math Primer for CG
- Ref Interactive Computer Graphics, Chap. 4, E.
Angel
2Contents
- Scalar, Vector, Point
- Change of Basis
- Frame
- Change of Frame
- Affine Sum, Convex Combination, Convex Hull,
- Case Study shooting game
3Introduction
- 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
4Scalars Live in Real Space
- ?a,b,g?S
- Commutative
- abba
- a bb a
- Associative
- a (b g)(a b) g
- a(bg)(ab)g
- Distributive
- a (bg)(a b)(a g)
- Additive multiplicative inverse
- a(-a)0, a a-11
- Two fundamental operations are defined between
pairs - Addition, multiplication
- Closure
- ?a,b?S,
- ab?S, ab?S
5Real Analysis
- The study of real numbers
-
- If you are interested, see Analysis WebNotes
- http//www.math.unl.edu/webnotes/contents/chapter
s.htm
6Vectors 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, uv?V
- Commutative
- uvvu
- Associative
- u(vw)(uv)w
- Distributive
- a(uv)auav
- (ab)uaubu
7Vector Space (cont)
- Linear combination
- ua1u1a2u2anun
- Linear independent
- Only set of scalars such that
- ua1u1a2u2anun
- is zero
- a1a2an0
- Basis
- a set of linearly independent vectors that span
the space
8Vector Space change of basis
- represent any vector uniquely in a basis
- change of basis
9Example
New Basis
10Points 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
11Affine Space change of frames
- Represent point in a frame
- Change of frame
12Euclidean Space
- Supplement vector space with the notion of
distance - New operation
- Inner (dot) product
- ?a,b?S ?u,v,w?V
- u vv u
- (aubv) wau w bv w
- v vgt0 (v?0)
- 0 00
- u v0 ? u and v are orthogonal
- v(v v)½
- u vuv cosq
13Summary Mathematical Spaces
Real Space (Scalar)
Vector Space (Scalar, Vector)
Euclidean Space (Scalar, Vector) distance
Affine Space (Scalar, Vector, Point) location
14Affine Sum
- In affine space, point addition is only defined
in the following case
Point addition is allowed only if their weights
add up to one
15Affine Sum (cont)
- More generally,
- Convex Combination
- A particular affine sum where weights are
non-negative
16Convex Hull
17Now, how to apply these math
- Besides change of basis/frame
18Ex Parametric Equation of a Line
19Ex Plane, Triangle, Parallelogram
R
T(a,b)
P
Q
S(a)
(infinite) Plane
Parallelogram
Triangle
20Ex Homogeneous Coordinates
- A unified representation scheme in affine space
for points and vectors - Change of Frame subsume change of basis
21Affine Space coordinate system
- fixing the origin of the vectors of coordinate
system at P0 - 4x1 vector
- Unified vector point representation
- homogeneous coordinate
- distinguish point vector
- 4x4 matrix algebra for change in frames
Point a1 a2 a3 1 Frame u1 u2 u3 P0
Vector a1 a2 a3 0 Frame u1 u2 u3 P0
22Ex Shooting (AABB)
- Intersection can be checked using 3D Sutherland
algorithm
23Cohen-Sutherland Line-Clipping Algorithm
Trivially accept Trivially reject clipping
24Ex Shooting (OBB)
- Change of frame then apply Sutherland algorithm
in the local frame
25Ex Ray-Triangle Intersection
26Ex Shooting (discrete version)
27Ex Shooting (continuous version)
28Exercise
- Convex Hull prove convex combination yields the
shape you imagine