280 likes | 402 Views
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.
E N D
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…
Two fundamental operations are defined between pairs: Addition, multiplication Closure a,bS, a+bS, a·bS a,b,gS Commutative a+b=b+a a · b=b · a Associative a ·(b · g)=(a · b) · g a+(b+g)=(a+b)+g Distributive a ·(b+g)=(a · b)+(a · g) Additive & multiplicative inverse a+(-a)=0, a · a-1=1 Scalars: Live in Real Space
Real Analysis • The study of real numbers • … • If you are interested, see Analysis WebNotes: http://www.math.unl.edu/~webnotes/contents/chapters.htm
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,vV, u+vV Commutative u+v=v+u Associative u+(v+w)=(u+v)+w Distributive a(u+v)=au+av (a+b)u=au+bu Vectors: Live in Vector Space
Linear combination u=a1u1+a2u2+…+anun Linear independent Only set of scalars such that u=a1u1+a2u2+…+anun is zero a1=a2=…=an=0 Basis a set of linearly independent vectors that span the space Vector Space (cont)
represent any vector uniquely in a basis change of basis Vector Space: change of basis
Example New Basis
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 Points: Live in Affine Space
Represent point in a frame Change of frame Affine Space: change of frames
Supplement vector space with the notion of distance New operation Inner (dot) product a,bS u,v,wV u · v=v · u (au+bv) · w=au · w + bv · w v · v>0 (v0) 0 · 0=0 u · v=0 u and v are orthogonal |v|=(v · v)½ u · v=|u||v| cosq Euclidean Space
Summary: Mathematical Spaces Real Space (Scalar) Vector Space (Scalar, Vector) Euclidean Space (Scalar, Vector) [distance] Affine Space (Scalar, Vector, Point) [location]
R P(a) Q Affine 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
Affine Sum (cont) • More generally, • Convex Combination • A particular affine sum where weights are non-negative
Now, how to apply these math Besides change of basis/frame…
R S(a) Q R S(a) Q Ex: Parametric Equation of a Line
Ex: Plane, Triangle, Parallelogram R T(a,b) P Q S(a) (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
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 Affine Space: coordinate system Point: [a1a2a3 1] Frame: [u1u2u3 P0] Vector: [a1a2a3 0] Frame: [u1u2u3 P0]
Intersection can be checked using 3D Sutherland algorithm Ex: Shooting (AABB)
Cohen-Sutherland Line-Clipping Algorithm Trivially accept Trivially reject clipping
Change of frame then apply Sutherland algorithm in the local frame Ex: Shooting (OBB)
Exercise • Convex Hull: prove convex combination yields the shape you imagine