CSE 681 Brief Review: Matrices, Vectors, and Transformations PowerPoint PPT Presentation

presentation player overlay
1 / 48
About This Presentation
Transcript and Presenter's Notes

Title: CSE 681 Brief Review: Matrices, Vectors, and Transformations


1
CSE 681Brief ReviewMatrices, Vectors, and
Transformations
2
Overview
  • Mathematical toolbox
  • Review basic matrix and vector algebra
  • Line representation
  • Affine transformations
  • Composing transformations
  • Axial rotations Euler angles
  • Rotation about an arbitrary axis

3
What is a Matrix?
  • A matrix is a set of elements, organized into
    rows and columns

rows
columns
4
Basic Operations
  • Addition, Subtraction, Multiplication

Just add elements
Just subtract elements
Multiply each row by each column
5
Multiplication
  • Is AB BA? Maybe, but maybe not!
  • Multiplication is NOT commutative!

6
Inverse of a Matrix
  • Identity matrix AI A
  • Inverse MatrixAA-1 I
  • Useful equivalence(ABC)-1 C-1B-1A-1

7
Determinant of a 2 x 2 Matrix
  • Useful for inversion
  • If det(A) 0
  • Then A has no inverse
  • Easy for a 2 x 2 matrix

8
Determinant of a 3 x 3 Matrix
Sum from left to right Subtract from right to
left Note n! terms
9
Inverse of a 3 x 3 Matrix
  • Append the identity matrix to A
  • Apply Gaussian Elimination so that A turns into
    the identity
  • Transform the identity matrix as you go
  • The identity has become the inverse!

10
Vector Operations
  • Vector 1 x N matrix
  • Looks like a point
  • Vector has its tail at the origin head at the
    point
  • Magnitude (length) and direction

y
v
x
11
Vectors Dot Product
Think of the dot product as a matrix
multiplication
The magnitude is the dot product of a vector with
itself
The dot product is also related to the angle
between the two vectors
12
Dot Product
  • A . B B . A
  • If A and B are unit vectors, A . B cos(q)
  • Remember, A . B A B cos(q)
  • If A is a unit vector, A . B is length of B
    projected onto A

13
Vectors Cross Product
  • A x B C, where vector C is perpendicular to A
    and B
  • The magnitude of C is proportional to the sine of
    the angle between A and B
  • The direction of C depends on the handedness of
    the coordinate system.

14
Cross Product
  • A x B -(B x A)
  • A x B is orthogonal to plane defined by A and B
  • If A and B are unit vectors, A x B sin(?)

15
Line Equation
  • We need a way to represent a ray, i.e. an
    infinite line
  • How would you define a line mathematically?

16
Line Equation
  • Two points determine a line, say between
    endpoints P0(x, y, z) and P1(x, y, z)
  • A line equation of the form f (x, y, z) is
    cumbersome since it depends upon on all three
    variables simultaneously
  • More convenient to define the line with a single
    variable
  • Will become clearer when we implement our ray
    tracer
  • How do we do this?

17
Parametric Line Equation
  • Define a single variable t that parameterizes the
    line simultaneously for all dimensions x, y, and
    z
  • P(t) P0(x, y, z) (1 t) P1(x, y, z) t
  • where 0 t 1.0

t 1
t 0
P1
P0
18
Parametric Line Equation
  • Re-write P(t)
  • P(t) P0(x, y, z) t D(x, y, z)
  • where D(x, y, z) P1(x, y, z) P0(x, y, z)
  • Furthermore,
  • x(t) P0(x) t Dx
  • y(t) P0(y) t Dy
  • z(t) P0(z) t Dz

19
ReviewTransformations
20
Transformations - Modeling
21
Modeling
How do I place the spheres ?
22
Viewing
Orthographic
Perspective
23
Modeling Transformations
  • Transform objects/points

Transform coordinate system
24
Affine Transformations
  • A transformation that preserves
  • Collinearity
  • All points lying on a line initially still lie on
    a line after the transformation
  • Parallel lines stay parallel
  • Ratios of distances
  • The midpoint of a line segment remains the
    midpoint after transformation
  • Does not necessarily preserve lengths or angles

25
Affine Transformations
  • Lets talk about transforming points
  • Transform P (x, y, z) to Q (x, y, z)
  • General form of an Affine transformation
  • x m11x m12 y m13z m14
  • y m21 x m22 y m23z m24
  • z m31 x m32 y m33z m34

26
Translation
  • Translation by (tx, ty, tz)
  • x x tx
  • y y ty
  • z z tz

(tx, ty, tz)
27
Scaling
  • Scaling by (sx, sy, sz)
  • x sx x
  • y sy y
  • z sz z

28
Rotation
  • Rotation counter-clockwise by angle ? around the
    z-axis
  • x x cos(?) y sin(?)
  • y x sin(?) y cos(?)
  • z z

Derivation x r cos(?) y r sin(?) x r
cos(? ?) r cos(?) cos(?) r sin(?) sin(?)
x cos(?) y sin(?) y r sin(? ?) r cos(?)
sin(?) r sin(?) cos(?) x sin(?) y cos(?)
29
Rotation Around the x-axis
  • Rotation counter-clockwise by angle ? around the
    x-axis
  • x x
  • y y cos(?) z sin(?)
  • z y sin(?) z cos(?)

z
?
y
x
30
Rotation Around the y-axis
  • Rotation counter-clockwise by angle ? around the
    y-axis
  • y y
  • z z cos(?) x sin(?)
  • x z sin(?) x cos(?)
  • Or
  • x x cos(?) z sin(?)
  • y y
  • z x sin(?) z cos(?)

x
?
z
y
31
Matrix Multiplication
  • Scaling by (sx, sy, sz)
  • x sx x
  • y sy y
  • z sz z
  • Rotation counter-clockwise by angle ? around the
    z-axis
  • x x cos(?) y sin(?)
  • y x sin(?) y cos(?)
  • z z
  • Translation by (tx, ty, tz)
  • x x tx
  • y y ty
  • z z tz

32
Homogeneous Coordinates
  • Represent P by (x, y, z, 1) and Q by (x, y, z,
    1)
  • Translation by (tx, ty, tz)
  • x x tx
  • y y ty
  • z z tz
  • Scaling by (sx, sy, sz)
  • x sx x
  • y sy y
  • z sz z

33
Rotation Matrices
  • Rotation counter-clockwise by angle ? around the
    z-axis
  • x x cos(?) y sin(?)
  • y x sin(?) y cos(?)
  • z z
  • Rotation counter-clockwise by angle ? around the
    x-axis
  • x x
  • y y cos(?) z sin(?)
  • z y sin(?) z cos(?)
  • Rotation counter-clockwise by angle ? around the
    y-axis
  • x x cos(?) z sin(?)
  • y y
  • z x sin(?) z cos(?)

34
Affine Transformation Matrix
  • Affine transformation
  • x m11 x m12 y m13 z m14
  • y m21 x m22 y m23 z m24
  • z m31 x m32 y m33 z m34
  • Transformation Matrix

35
Shearing
  • Shear along the x-axis
  • x x hy
  • y y
  • z z

36
Reflection
  • Reflection across the x-axis
  • x x
  • y (-1) y
  • z z

Reflection is a special case of scaling!
37
Compose Transformations
38
Compose Transformation Matrices
  • Scale by (2, 1, 1)
  • Rotate by 30 counter-clockwise around the
    z-axis
  • Translate by (0, -50, 0).

Translate
Rotate
Scale
39
Compose Transformation Matrices
  • Scale by (2, 1, 1)
  • Translate by (20, 5, 0)
  • Rotate by 30 counter-clockwise around the
    z-axis
  • Translate by (0, -50, 0).

40
Order Matters!
  • Transformations are not necessarily commutative!
  • Translate by (20, 0, 0).
  • Rotate by 30?.
  • Rotate by 30?.
  • Translate by (20, 0, 0).

41
Order of Transformation Matrices
  • Apply transformation matrices from right to left.
  • Translate by (20, 0, 0).
  • Rotate by 30?.
  • Rotate by 30?.
  • Translate by (20, 0, 0).

42
Elementary Transformations
  • Theorem Every affine transformation can be
    decomposed into elementary operations
  • (For example a rotation, then a scaling and
    finally a translation)
  • Elementary transformations
  • Translation
  • Rotation
  • Scaling
  • Shear

43
Eulers Theorem
  • Every rotation around the origin can be
    decomposed into a rotation around the x-axis
    followed by a rotation around the y-axis followed
    by a rotation around the z-axis

44
Fixed Point Transformations
  • Sometimes it is convenient to transform to the
    origin first, then perform your operations
  • Take the hatchet in this example

45
Fixed Point Transforms
46
Fixed Point Scaling
  • Assuming that (xp, yp) is our fixed point (2D
    example)
  • 1. Translate (xp, yp) to the origin
  • 2. Scale by Sx and Sy
  • 3. Translate the origin back to (xp, yp)
  • Expressing (x, y) in terms of (x, y) we
    get

47
Rotation About An Arbitrary Axis
y
u
Q
Rotate P to Q by angle b about an arbitrary axis
(vector) u?
P
x
z
48
Rotation About An Arbitrary Axis
  • Make axis u coincident with axis x
  • Two rotations Rz(-f) Ry(q)
  • Apply transformation to P as well
  • Rotate P around x-axis Rx(b)
  • Undo earlier rotations Ry(-q) Rz(f)
  • R Ry(-q) Rz(f) Rx(b) Rz(-f) Ry(q) Eulers
    Theorem!

What OpenGL command can construct this matrix?
glRotate
Write a Comment
User Comments (0)
About PowerShow.com