Lecture_004_Spatial_Transformations

Linear Transformations

Linear Transformations

Linear Transformation Inariant

Linear Transformation Inariant

Rotation

Rotation Invariant

Rotation Invariant

Rotation in 3D

Rotation in 3D

The transpose of a rotation is its inverse: observe klzzwxh:0004, which means klzzwxh:0005

The transpose of a rotation is its inverse: observe R^TR = I, which means R^T = R^{-1}

Orthogonal Transformation: the transformation that preserve distance and origin

Rotation vs. Reflection

Rotation vs. Reflection

Scaling

Scaling: preserve direction while change magnitude

Negative Scaling in 2D and 3D

Negative Scaling in 2D and 3D

Negative Scaling: a sequence of reflections (how many reflections depends on the dimension of the space)

Nonuniform Scaling: a symmetric matrix A := R^TDR

Symmetric Matrix: a matrix A such that A = A^T.

Shear

Shear in direction u according to its distance along a fixed vector v is f_{u, v}(x) = x + (x \cdot v)u.

The transformation can be represented as A_{u, v} = I + uv^t \implies A_{u, v}x = Ix + u(v \cdot x)

// QUESTION: Can we linear time discompose a sheer to standard basis? Two sheers together is still a sheer or not?

Decomposition of Linear Transformation

No unique way to write a given linear transformation as a composition of basic transformations, but many useful decomposition:

Singular Value Decomposition

Singular Value Decomposition

Polar Decomposition: decompose A into orthogonal matrix Q and symmetric positive-semidefinite matrix P. So that A = QP.

Spectral Decomposition: Since P is symmetirc, we can do spectral decomposition P = VDV^T where V is orthogonal and D is diagonal. So that A = QVDV^T

Singular Value Decomposition: A = QVDV^T = UDV^T where we combine two orthogonal matrix U = QV. (Every matrix has a singular value decomposition)

Interpolation Using Decomposition

Polar Interpolation of Transformations

Polar Interpolation of Transformations

Interpolating Transformations:

Candy-Wrapper Artefact: Bad visual result from interpolation using linear decomposition

Candy-Wrapper Artefact: Bad visual result from interpolation using linear decomposition

Translation

Homogeneous Coordinates

Homogeneous Coordinates use cases

Homogeneous Coordinates use cases

Translation: it is not linear transformation (it is affine). We can make transformation linear using 4th dimension with Homogeneous Coordinates.

Idea of Homogeneous Coordinates: Fix origin o and a point in 2D space specified by plane z = 1 p \in \mathbb{R}^2 can be represented by any points (except the origin) along the line that contains o and p.

A Translation in 2D is a Sheer in 3D

A Translation in 2D is a Sheer in 3D

Proof it is a sheer ing 3D:

A sheer in matrix form: f_{u, v}(x) = (I + uv^T)x. For the use in homogeneous coordinates to represent 2D coordinates, it is always the case v = (0, 0, 1). So we have matrix \begin{bmatrix}1 & 0 & u_1\\ 0 & 1 & u_2\\ 0 & 0 & 1\\ \end{bmatrix}. Observe the following:

\begin{bmatrix}1 & 0 & u_1\\ 0 & 1 & u_2\\ 0 & 0 & 1\\ \end{bmatrix} \begin{bmatrix} cp_1\\ cp_2\\ c\\ \end{bmatrix} = \begin{bmatrix} c(p_1 + u_1)\\ c(p_2 + u_2)\\ c\\ \end{bmatrix} \xrightarrow{1/c} \begin{bmatrix} p_1 + u_1\\ p_2 + u_2\\ \end{bmatrix}

Other Transformation in Homogeneous Coordinates

Other Transformation in Homogeneous Coordinates

Transformation of Homogeneous Coordinates in Matrix Form in 3D

Transformation of Homogeneous Coordinates in Matrix Form in 3D

Advantages:

Dealing with Unit Vectors (like Normal)

Observe that Normal Vector Get Translated with Triangle, that's wrong!

Observe that Normal Vector Get Translated with Triangle, that's wrong!

A Trick to Write Normal in Homogeneous Coordinate is to set 4th Component to Zero

A Trick to Write Normal in Homogeneous Coordinate is to set 4th Component to Zero

In general:

The problem is, when we want to convert vector in homogeneous coordinate back to 3D coordinate, we might encounter division by 0 (since c = 0)

As klzzwxh:0047 for translating homogeneous coordinate to 3D coordinate

As c \rightarrow 0 for translating homogeneous coordinate to 3D coordinate

Mathematical intuition: as c \rightarrow 0, we get vectors that represent a line (or a direction towards infinity), which is intuitive for unit vectors since they suppose to only give us a direction.

Practical solution: branch if to check for 0.

Perspective Projection

Screen Projection Can be Done by Copy klzzwxh:0052 Coordinate to Homogeneous Coordinate and Then Translate to 3D Coordinate and Throw Away klzzwxh:0053 Component

Screen Projection Can be Done by Copy z Coordinate to Homogeneous Coordinate and Then Translate to 3D Coordinate and Throw Away z Component

And Then Translate to Nasty Conventional Coordinate (Pixel Coordinate)

And Then Translate to Nasty Conventional Coordinate (Pixel Coordinate)

Scene Graph

Scene Graph: Store Transformation Relative to Each Other in Hierarchical Tree

Scene Graph: Store Transformation Relative to Each Other in Hierarchical Tree

Note: Keep transformation on a stack to reduce redundant multiplication

  1. you might push() a transformation (from body position to leg position)
  2. and then draw something (for example a leg)
  3. and then pop() a transformation (from leg position to body position)

Instancing Tree: dandelion are replaced by pointers

Instancing Tree: dandelion are replaced by pointers

Instancing: Used to draw many copies of the same object in a scene. It can save memory so that the same model only get loaded once in the tree.

Order Matters in Composing Transformations

Order Matters in Composing Transformations

Rotation an Object by its Center is Computationally Hard without Separating Object, World, View Spaces, (and Pixel Space)

Rotation an Object by its Center is Computationally Hard without Separating Object, World, View Spaces, (and Pixel Space)

Table of Content