280 likes | 503 Views
Week 4 - Friday. CS361. Last time. What did we talk about last time? Texturing in XNA Homogeneous notation Geometric techniques Lines (2D and 3D) Planes. Questions?. Project 1. Implicit planes.
E N D
Week 4 - Friday CS361
Last time • What did we talk about last time? • Texturing in XNA • Homogeneous notation • Geometric techniques • Lines (2D and 3D) • Planes
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
Cross product • The cross product of two vectors finds a vector that is orthogonal to both • For 3D vectors u and v in an orthonormal basis, the cross product w is:
Practice with a plane • Plane defined by: • (1, 3, 2) • (2, 5, 2) • (3, 8, 2) • Where is (3, 3, 2)? • What about (3, 4, 5)?
Transforms • A transform is an operation that changes points, vectors or colors • We can use them to position and animate objects, lights, and cameras • A linear transform is one that holds over vector addition and scalar multiplication • Rotation • Scaling • Can be represented by a 3 x 3 matrix
Affine transforms • Adding a vector after a linear transform makes an affine transform • Affine transforms can be stored in a 4 x 4 matrix using homogeneous notation • Affine transforms: • Translation • Rotation • Scaling • Reflection • Shearing
Translation • Move a point from one place to another by vector t = (tx, ty, tz) • We can represent this with translation matrix T
Rotation • Rotation, like translation, is a rigid-body transform (points don't change distance from each other and handedness doesn't change) • An orientation matrix is used to define up and forward (usually for a camera) • We usually express rotation in terms of 3 separate x, y, and z rotation matrices
Rotation around a point • Usually all the rotations are multiplied together before translations • But if you want to rotate around a point • Translate so that that point lies at the origin • Perform rotations • Translate back
Scaling • Scaling is easy and can be done for all axes as the same time with matrix S • If sx = sy = sz, the scaling is called uniform or isotropic and nonuniform or anisotropic otherwise
Shearing • A shearing transform distorts one dimension in terms of another with parameter s • Thus, there are six shearing matrices Hxy(s), Hxz(s), Hyx(s), Hyz(s), Hzx(s), and Hzy(s) • Here's an example of Hxz(s):
To make a shearing matrix • To make Hij(s), start with the identity matrix and put s in row i, column j • See how the only the affected dimension changes
Concatenation of transforms • Because matrix multiplications are not commutative, order of transforms matters • Still, parts (or the entirety) of the transform can be precomputed and stored as a single matrix • Note that matrices are applied from right to left, thus TRSp scales point p, rotates it, then translates it
Non-commutativity of transforms • This example from the book shows how the same sets of transforms, applied in different orders, can have different outcomes
Rigid-body transforms • A rigid-body transform preserves lengths, angles, and handedness • We can write any rigid-body transform X as a translation matrix T(t) multiplied by a rotation matrix R
Inverse of a rigid-body transform • Because R is orthogonal, its inverse is its transpose • Because of the nature of a translation, its inverse is just its negative • Thus, the inverse of X is • X-1 = (T(t)R)-1 = R-1T(t)-1 = RTT(-t)
Next time… • Normal transforms • Inverses • Euler transform • Matrix decomposition • Rotation around an arbitrary axis • Quaternions
Reminders • Keep reading Chapter 4 • Finish Project 1, due tonight by 11:59