Transcript Document

Mathematical Foundations
Sections
A-1 to A-5
Some of the material in these slides may have been adapted from university of Virginia, MIT and Åbo Akademi University
Mathematical Foundations
● I’ll give a brief, informal review of some of the
mathematical tools we’ll employ
■ Geometry (2D, 3D)
■ Trigonometry
■ Vector and affine spaces
○ Points, vectors, and coordinates
■ Dot and cross products
■ Linear transforms and matrices
● I know that everyone knows that…
2
2D Geometry
● Know your high-school geometry:
■ Total angle around a circle is 360° or 2π radians
■ When two lines cross:
○ Opposite angles are equivalent
○ Angles along line sum to 180°
■ Similar triangles:
○ All corresponding angles are equivalent
○ Corresponding pairs of sides have the same length ratio and are
separated by equivalent angles
○ Any corresponding pairs of sides have same length ratio
3
Trigonometry
● Sine: “opposite over hypotenuse”
● Cosine: “adjacent over hypotenuse”
● Tangent: “opposite over adjacent”
● Unit circle definitions:
■ sin () = y/z
■ cos () = x/z
■ tan () = y/x
■ Z = sqrt(x2 + y2)
■ Degrees vs Radians
■ Etc…
Z
y

x
4
3D Geometry
● To model, animate, and render 3D scenes, we must
specify:
■ Location
■ Displacement from arbitrary locations
■ Orientation
● We’ll look at two types of spaces:
■ Vector spaces
■ Affine spaces
● We will often be sloppy about the distinction
5
Co-ordinates
● Cartesian
■ 3 Perpendicular Axes
■ Right Hand Rule
z
x
● Curvilinear
y
■ Any non-cartesian
■ Formed by the intersection of any 3 surfaces
■ Each Surface is constructed by fixinging one co-ordinate
■ May be orthogonal
6
Cylindrical Co-ordinate
•
•
•
•
•
Related to Cartesian
A surface is formed by fixing one co-ordinate
Plane including the z-axis is formed by fixing q
Plane intersecting z-axis is formed by fixing z
Cylinder is formed by fixing r
z
x-axis
q
y-axis
r
● How to convert from Cylindrical to Cartesian
7
Polar Co-ordinates
•
•
•
•
3 co-ordinates: (r,q,j)
Surface of constant r is sphere
Surface of constant j is a cone
Surface of a constant q is a plane including z- axis
z
j
x-axis
q
y-axis
r
● How to convert from Polar to Cartesian
8
Vector Spaces
● A space is basically a set of elements with operations
defined on the elements
● Two types of elements:
■ Scalars (real numbers): a, b, g, d, …
■ Vectors (n-tuples): u, v, w, …
● Supports two operations:
■ Addition operation u + v, with:
○ Identity 0
v+0=v
○ Inverse v + (-v) = 0
■ Scalar multiplication:
○ Distributive rule:
a(u + v) = a(u) + a(v)
(a + b)u = au + bu
9
Vector Spaces
● A linear combination of vectors results in a new
vector:
v = a1v1 + a2v2 + … + anvn
● If the only set of scalars such that
a1v1 + a2v2 + … + anvn = 0
is
a1 = a2 = … = a3 = 0
then we say the vectors are linearly independent
● The dimension of a space is the greatest number of linearly
independent vectors possible in a vector set
● For a vector space of dimension n, any set of n linearly
independent vectors form a basis
10
Vector Spaces:
A Familiar Example
● Our common notion of vectors in a 2D plane is (you
guessed it) a vector space:
■ Vectors are “arrows” rooted at the origin
■ Scalar multiplication “streches” the arrow, changing its length
(magnitude) but not its direction
■ Addition can be constructed using parallelogram ( “trapezoid rule”)
u+v
y
v
u
x
11
Vector Spaces: Basis Vectors
● Given a basis for a vector space:
■ Each vector in the space is a unique linear combination of the basis
vectors
■ The coordinates of a vector are the scalars from this linear combination
■ Orthonormal Basis
○ Orthogonal uk.uj = 0, j  k
○ Unit length uk.uk = 1
■ Best-known example: Cartesian coordinates
○ Draw example on the board
○ (i, j, k)
■ Note that a given vector v will have different coordinates for different
bases
12
Vectors And Points
● We commonly use vectors to represent:
■ Direction (i.e., orientation)
■ Points in space (i.e., location)
■ Displacements from point to point
● But we want points and directions to behave
differently
■ Ex: To translate something means to move it without
changing its orientation
■ Translation of a point = different point
■ Translation of a direction = same direction
13
Affine Spaces
● An affine space is what is left of a vector space after
you've forgotten which point is the origin.
● Points support these operations
Q
■ Point-point subtraction:
Q-P=v
○ Result is a vector pointing from P to Q
■ Vector-point addition: P + v = Q
○ Result is a new point
○ P+0=P
v
P
■ Note that the addition of two points is undefined
■ Scaler times point is undefined
14
Affine Spaces
● Points, like vectors, can be expressed in coordinates
■ The definition uses an affine combination
■ Net effect is same: expressing a point in terms of a basis
● Thus the common practice of representing points as
vectors with coordinates
● Be careful to avoid nonsensical operations
■ Point + point
■ Scalar * point
15
Affine Lines: An Aside
● Parametric representation of a line with a direction
vector d and a point P1 on the line:
P(a) = Porigin + ad
● Restricting 0  a produces a ray in the direction of
the vector d
● Setting d to P - Q and restricting 1  a  0 produces a
line segment between P and Q
16
Dot Product
● The dot product or, more generally, inner product of
two vectors is a scalar:
v1 • v2 = x1x2 + y1y2 + z1z2
(in 3D)
● Useful for many purposes
■ Computing the length of a vector: length(v) = sqrt(v • v)
■ Normalizing a vector, making it unit-length
■ Computing the angle between two vectors:
u • v = |u| |v| cos(θ)
■ Checking two vectors for orthogonality
■ Projecting one vector onto another
v
θ
u
17
Cross Product
● The cross product or vector product of two vectors is a vector:
 y1 z 2  y 2 z1 
v1  v 2   ( x1 z 2  x 2 z1)
 x1 y 2  x 2 y1 
● v1xv2 = u|v1||v2|sin q
● Cross product of two vectors is orthogonal to both
● Right-hand rule dictates direction of cross product
● Cross product is handy for finding surface orientation
■ Lighting
■ Visibility
● Not Associative
● Distributive
18
Linear Transformations
● A linear transformation:
■ Maps one vector to another
■ Preserves linear combinations
● Thus behavior of linear transformation is completely
determined by what it does to a basis
● Turns out any linear transform can be represented by
a matrix
19
Matrices
● By convention, matrix element Mrc is located at row r
and column c:
 M11 M12
 M21 M22
M
 


Mm1 Mm2
 M1n 
 M2n 

 

 Mmn 
● By convention (mathematical) ,
vectors are columns:
 v1 


v   v 2
 v 3 
20
Matrices
● Matrix-vector multiplication applies a linear
transformation to a vector:
 M11 M12 M13  vx 
M  v  M 21 M 22 M 23  vy 
M31 M32 M33  vz 
● Recall how to do matrix multiplication
● Dot product
● Cross product is the determinant of a matrix
21
Matrices
● Matrix multiplication is NOT commutative
● Matrix multiplication is associative
● Linear transformations can be represented as matrix
multiplications
● When we talk about transformations, we will see that
all linear transformations can be represented by
matrices
22
Matrix Transformations
● A sequence or composition of linear transformations
corresponds to the product of the corresponding
matrices
■ Note: the matrices to the right affect vector first
■ Note: order of matrices matters!
● The identity matrix I has no effect in multiplication
● Some (not all) matrices have an inverse:
det( M )  0
M 1 (M(v ))  v
23