Joshua Barczak CMSC 435 UMBC Miscellaneous Math Joshua Barczak CMSC 435 UMBC
You had better know… Basic Algebra The Quadratic Formula Geometry and Trigonometry SOHCAHTOA or however you learned it Pathagorean theorem Angles and lines What “the matrix” is…
Today Barrage of math facts useful to graphics Vectors Matrices Lines/Planes Triangles Implicits
Vectors N-vector Tuple of N of scalars Arbitrary dimension 2, 3, 4 are ubiquitous in graphics
Vectors Vectors are arrows protruding from a point… Direction Magnitude z x y
Points … and points are vectors from the origin Direction from origin Magnitude=Distance z x y
Spherical Coordinates 2 angles + Distance Wikipedia
Vectors Some definitions: Normalization Orthogonal Perpendicular Magnitude (Length): Normalized Length=1 Normalization Divide by length
Surface Normals Surface normal = Normalized vector perendicular to some surface Perpendicular to polygon plane Perpendicular to curve tangent at some point N N
Arithmetic Commutative Distributive Associative
Vector Addition u v u+v u v u+v = v+u u v Put them end to end, then connect the dots… Order doesn’t matter….
Vector Subtraction Subtracting vectors gives a vector between the two “tips” xb-xa V yb-ya A B
Point Subtraction Subtracting points gives a vector from last to first, with first as its “origin”… P1 V P0 y1-y0 x1-x0
Vector Scaling au axu ayu u xu yu Scales vector length by a
Dot Product q u,v are orthogonal u,v are perpendicular cos(theta) = 0 u.v=0
Dot Product Implications: Same direction Opposite direction u.v = |u||v| Length is sqrt(x.x) Opposite direction u.v = -|u||v| Normalized vectors Cosine of angle Same sign, same side… N
Dot Product u v’ v Dot products can be used to project onto other vectors
Dot Product More useful facts (a,b,c vectors. x,y scalars) Just like multiplication… If you’re queasy about dot products, go home and prove all these….
Basis Vectors All vectors can be written as linear combinations of other vectors
Basis Vectors Basis: Orthogonal basis Orthonormal basis “Linearly independent set of vectors that span a space” One is not a weighted sum of the others Orthogonal basis Basis S.T. all vectors are perpendicular Orthonormal basis Orthogonal basis with unit-length vectors
Basis Vectors Vectors are always relative to some basis The “Default” basis vectors are the coordinate axes… B A X+ Y+ D C
Basis Vectors ….and a point is relative to an origin AND some basis vectors B A X+ Y+ D C
Coordinate System Basis Vectors + Origin Cartesian Coordinates Basis is a “span” Sometimes basis is orthonormal Cartesian Coordinates Origin is 0,0,0 Basis Vectors X+,Y+,Z+ X Y Z Wikipedia
Change of Basis To write a vector v in terms of new basis vectors Bx and By we…. xv v By yv Bx This will become very important later…
Change of Basis …project it onto each basis vector. Bx, By are the new coordinate axes… x’ v’ By y’ Bx This will become very important later…
Change of Coordinate System To switch coordinate systems we… By P O Bx This will become very important later…
Change of Coordinate System …write P in terms of new origin, then…. By P’ O Bx This will become very important later…
Change of Coordinate System …project onto new basis vectors By Q O Bx This will become very important later…
Change of Coordinate System To go back out, add scaled basis vectors to origin… By Q P O Bx This will become very important later…
Handedness X Y Z Y X Y Z Z X X Y Z Y X Y Z Z X Wikipedia Wikipedia, Reflected X Y Z Y X Y Z Z X
Cross Product Wikipedia
Cross Product Perpendicular to inputs Length Length is area of parallelogram q a b a x b
Cross Product If a,b are orthonormal, axb is normalized If a,b have same or opposite direction, axb is zero Also: Anticommutative Distributive NOT associative q a b a x b
Cross Product More potentially useful facts…
Building an Orthogonal Basis (AxB)xA B B (AxB)xA A A A A AxB AxB AxB
2D “Cross Product” r1 r0 Signed area of Parallelogram. Negative Vectors are clockwise Positive Vectors are counterclockwise
2D “Cross Product” Application: Given two points, which side of their line is a third point on? B C A
2D “Sidedness” Use 2D Cross product: Positive Left Negative Right Zero Co-linear B C A
Matrices N row vectors M column vectors NxM scalars… If you have not taken your red pill, do so NOW…
Matrix Determinant(2x2) Didn’t we see this already…? c1 c0 Signed area of Parallelogram. Negative Vectors are clockwise Positive Vectors are counterclockwise Positive Identity matrix
Matrix Determinant (3x3) Signed volume of that thing PositiveRight handed basis NegativeLeft handed basis Wikipedia
Matrix Multiplication
Matrix Multiplication …is just a bunch of dot products
Matrix/Vector Multiplication
Matrix/Vector Multiplication …. is also a bunch of dot products This IS change of basis Projection onto row/column vectors
Matrix Inverse If rows form an orthonormal basis, Inverse equals transpose Square matrix is invertible if it has non-zero determinant Zero determinant Zero area/volume Vectors do not span the full space… If det(M)=0, it goes flat…
Linear Interpolation In-betweening… s A A B t B C D t=0.25 t=0 t=0.75
Implicit 2D Lines You should know slope-intercept Lines also have an implicit form (x2,y2) (x1,y1) (A,B)
Implicit 2D Lines Point-Line Distance Plug point into line equation Result is scaled by length of [A,B] To “normalize” line, divide A,B,C by normal length (x2,y2) (x1,y1) (A,B) Negative Here Positive Here
3D Planes Planes are analogous to 2D Lines Plug in points for signed distance Positive “in front” Negative “behind” 0 On plane The rain in Spain…
3D Planes Plane from point and normal N P P1
3D Planes Plane from 3 Points Cross Product N P3 P2 P1
Triangle Area This again… Sign indicates vertex order… Positive: A,B,C counter-clockwise In 3D: Use magnitude of cross product… C B A
Point-In-Triangle Test Method 1: Three determinant tests. Check signs… Y P (blue) Z (red) X (green)
Point-In-Triangle Test Method 2: Extract line equations See earlier slides Test signed distances Same sign Inside B P C A
Barycentric Coordinates g=0 Ratios of areas a=0 B (0,1,0) a P g b C b=0 (0,0,1) A (1,0,0) Inside Triangle
Barycentric Coordinates Edge equations normalized to opposite vertex… g=0 a=0 b=1 g=1 a=1 b=0
Barycentric Interpolation Interpolation across triangle surface Weight per-vertex values by barycentric coordinates
Implicit Surfaces Surface Surface normal Set of all zeros of implicit function “Inside”Negative “Outside”Positive Surface normal Vector of partials “Gradient” Points in direction of greatest change in f
Implicit Surfaces …mmmmmm…. Formulii……