270 likes | 282 Views
This text provides an introduction to matrices, including operations and properties, as well as geometric techniques such as 2D and 3D lines, planes, and convex hulls.
E N D
Week 4 - Wednesday COMP 4290
Last time • What did we talk about last time? • Matrices
A matrix • A matrix M is a set of p x q scalars with each element named mij, where 0 ≤ i ≤ p – 1 and 0 ≤ j ≤ q – 1 • We display them as p rows and q columns
Operations • We will be interested in a number of operations on matrices, including: • Addition • Scalar multiplication • Transpose • Trace • Matrix-matrix multiplication • Determinant • Inverse
Multiplicative inverse of a matrix • For a square matrix M where |M| ≠ 0, there is a multiplicative inverse M-1 such that MM-1 = I • For implicit inverse, we only need to find v in the equation u = Mv, done as follows: • For cases up to 4 x 4, we can use the adjoint:
Notes about the inverse • For cases larger than 4 x 4, other methods are necessary: • Gaussian elimination • LU decomposition • Fortunately, we never need more than 4 x 4 in graphics • Properties of the inverse: • (M-1)T = (MT)-1 • (MN)-1 = N-1M-1
Orthogonal matrices • A square matrix is orthogonal if and only if its transpose is its inverse • MMT = MTM = I • Lots of special things are true about an orthogonal matrix M • |M| = ± 1 • M-1 = MT • MT is also orthogonal • ||Mu|| = ||u|| • Mu Mviffu v • If M and N are orthogonal, so is MN • An orthogonal matrix is equivalent to an orthonormal basis of vectors lined up together
Homogeneous notation • Why do we often have vectors of 4 things or 4 x 4 matrices in graphics? • We have points (locations) and vectors (directions) • What's really confusing is that we represent them the same way (in what looks like a vector for both) • We need to translate points but translation isn't meaningful for vectors • A 3 x 3 matrix can rotate, scale, or shear, but it can't translate
How we do it • We add an extra value to our vectors • It's a 0 if it’s a direction • It's a 1 if it's a point • Now we can do a rotation, scale, or shear with a matrix (with an extra row and column):
Translations • Then, we multiply by a translation matrix (which doesn't affect a direction vector) • Don't worry too much about how we make the transforms we want right now • We'll cover that Friday
2D lines • With vectors in the mix, we will describe lines slightly different than in the past • Explicit form: • r(t) = o + td • o is a point on the line and d is its direction vector • We can use an explicit formula to generate points based on parameter t • However, we will often prefer an implicit form that allows us to test to see if a point is above, below, or on a line
2D lines: implicit form • Let the line be called L described by the following equation: • ax + by + c = 0 • Let n be a vector (a, b) • Let p be a point (x, y) • p is on L if and only if • n • p + c = 0 • If p and q are both points on L then we can describe L with • n • (p – q) = 0 • Thus, n is perpendicular to L • n = (-(py- qy),(px – qx)) = (a, b)
Implicit form as a function • If we write f(p) = n • p + c • Assuming q L • f(p) = 0 iffp L • f(p) > 0 iffp lies on the same side as the point q + n • f(p) < 0 iffp lies on the same side as the point q - n • f(p) gives a (scaled) measure of the perpendicular distance from p to L • Distance(p) = f(p)/||n||
3D lines • One nice thing about vector lines is that the explicit form for 3D lines is the same as for 2D lines • r(t) = o + td • o is a point on the line and d is its direction vector • The only difference is that o and d are now 3D vectors
Planes • Once we are in 3D, we have to talk about planes as well • The explicit form of a plane is similar to a line: • p(u,v) = o + us + vt • o is a point on the plane • s and t are vectors that span the plane • s x t is the normal of the plane
Implicit planes • The implicit equation for a plane is just like the implicit for a line, except with an extra dimension • Let n be a vector (a, b, c) • Let p be a point (x, y, z) • p is on plane π if and only if • n • p + d = 0 • Since n is the normal of the plane we can compute it in a couple of ways: • n = s x t where s and t span the plane • n = (u – w) x (v – w) where u, v, and w are noncollinear points in the plane
Implicit plane function • Again, it works just like a line • If we write f(p) = n • p + d • Assuming q plane π • f(p) = 0 iffp π • f(p) > 0 iffp lies on the same side as the point q + n • f(p) < 0 iffp lies on the same side as the point q - n • f(p) again gives a (scaled) measure of the perpendicular distance from p to π • Distance(p) = f(p)/||n|| • This implies that Distance(0) = d, making d the shortest distance from the origin to the plane
Convex hull • Given a set of points in n-dimensional space, the convex hull is the smallest set of those points that guarantees that the straight line between any two points in the set is totally included in the set
Next time… • Trigonometry • Basic transforms
Reminders • Read Chapter 4 • Keep working on Project 1, due next Friday