Download presentation
Presentation is loading. Please wait.
1
Joshua Barczak CMSC 435 UMBC
Miscellaneous Math Joshua Barczak CMSC 435 UMBC
2
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…
3
Today Barrage of math facts useful to graphics Vectors Matrices
Lines/Planes Triangles Implicits
4
Vectors N-vector Tuple of N of scalars Arbitrary dimension
2, 3, 4 are ubiquitous in graphics
5
Vectors Vectors are arrows protruding from a point… Direction
Magnitude z x y
6
Points … and points are vectors from the origin Direction from origin
Magnitude=Distance z x y
7
Spherical Coordinates
2 angles + Distance Wikipedia
8
Vectors Some definitions: Normalization Orthogonal Perpendicular
Magnitude (Length): Normalized Length=1 Normalization Divide by length
9
Surface Normals Surface normal =
Normalized vector perendicular to some surface Perpendicular to polygon plane Perpendicular to curve tangent at some point N N
10
Arithmetic Commutative Distributive Associative
11
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….
12
Vector Subtraction Subtracting vectors gives a vector between the two “tips” xb-xa V yb-ya A B
13
Point Subtraction Subtracting points gives a vector from last to first, with first as its “origin”… P1 V P0 y1-y0 x1-x0
14
Vector Scaling au axu ayu u xu yu Scales vector length by a
15
Dot Product q u,v are orthogonal u,v are perpendicular
cos(theta) = 0 u.v=0
16
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
17
Dot Product u v’ v Dot products can be used to project onto other vectors
18
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….
19
Basis Vectors All vectors can be written as linear combinations of other vectors
20
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
21
Basis Vectors Vectors are always relative to some basis
The “Default” basis vectors are the coordinate axes… B A X+ Y+ D C
22
Basis Vectors ….and a point is relative to an origin AND some basis vectors B A X+ Y+ D C
23
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
24
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…
25
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…
26
Change of Coordinate System
To switch coordinate systems we… By P O Bx This will become very important later…
27
Change of Coordinate System
…write P in terms of new origin, then…. By P’ O Bx This will become very important later…
28
Change of Coordinate System
…project onto new basis vectors By Q O Bx This will become very important later…
29
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…
30
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
31
Cross Product Wikipedia
32
Cross Product Perpendicular to inputs Length
Length is area of parallelogram q a b a x b
33
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
34
Cross Product More potentially useful facts…
35
Building an Orthogonal Basis
(AxB)xA B B (AxB)xA A A A A AxB AxB AxB
36
2D “Cross Product” r1 r0 Signed area of Parallelogram.
Negative Vectors are clockwise Positive Vectors are counterclockwise
37
2D “Cross Product” Application:
Given two points, which side of their line is a third point on? B C A
38
2D “Sidedness” Use 2D Cross product: Positive Left Negative Right
Zero Co-linear B C A
39
Matrices N row vectors M column vectors NxM scalars…
If you have not taken your red pill, do so NOW…
40
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
41
Matrix Determinant (3x3)
Signed volume of that thing PositiveRight handed basis NegativeLeft handed basis Wikipedia
42
Matrix Multiplication
43
Matrix Multiplication
…is just a bunch of dot products
44
Matrix/Vector Multiplication
45
Matrix/Vector Multiplication
…. is also a bunch of dot products This IS change of basis Projection onto row/column vectors
46
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…
47
Linear Interpolation In-betweening… s A A B t B C D t=0.25 t=0 t=0.75
48
Implicit 2D Lines You should know slope-intercept
Lines also have an implicit form (x2,y2) (x1,y1) (A,B)
49
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
50
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…
51
3D Planes Plane from point and normal N P P1
52
3D Planes Plane from 3 Points Cross Product N P3 P2 P1
53
Triangle Area This again… Sign indicates vertex order…
Positive: A,B,C counter-clockwise In 3D: Use magnitude of cross product… C B A
54
Point-In-Triangle Test
Method 1: Three determinant tests. Check signs… Y P (blue) Z (red) X (green)
55
Point-In-Triangle Test
Method 2: Extract line equations See earlier slides Test signed distances Same sign Inside B P C A
56
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
57
Barycentric Coordinates
Edge equations normalized to opposite vertex… g=0 a=0 b=1 g=1 a=1 b=0
58
Barycentric Interpolation
Interpolation across triangle surface Weight per-vertex values by barycentric coordinates
59
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
60
Implicit Surfaces …mmmmmm…. Formulii……
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.