04 - Transformation

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/41

encourage image

There's no tags or description

Looks like no tags are added yet.

42 Terms

1
New cards

Transformation

A change applied to points/vectors to move, resize, or reorient an object. In graphics every transformation is represented as a matrix.

2
New cards

Three standard transformations

Translation, scale, and rotation.

3
New cards

Translation

Moves a point by adding an offset: (x, y, z) -> (x+dx, y+dy, z+dz). It is addition, so it can't be a plain 3x3 matrix. Applied to points only, never to vectors like normals.

4
New cards

Scale

Changes size by multiplying each coordinate by a scale factor: (sxx, syy, sz*z). Works about the origin and makes sense for both points and vectors.

5
New cards

Uniform vs non-uniform scale

Uniform = same factor on every axis. Non-uniform = different factors per axis. Non-uniform scale doesn't preserve angles, and some systems don't support it, so build non-uniform shapes into the model instead.

6
New cards

Rotation

Turns a point by an angle about an axis through the origin. A positive angle means counter-clockwise.

7
New cards

2D rotation equations

x' = x cos(a) - y sin(a), y' = x sin(a) + y cos(a). Derived from the angle-sum identities.

8
New cards

Reflection

Flips an object about a line (2D) or a plane (3D). Built by setting matrix entries to -1, since GLM has no reflection function.

9
New cards

Reflection handedness trap

A 3D reflection with an odd number of -1s turns a right-handed coordinate system into a left-handed one, so objects move in the opposite direction to what you expect.

10
New cards

Shear

Slides one side of an object over relative to the other, like pushing a deck of cards.

11
New cards

Point vs vector

A point is a position and can be translated. A vector is a direction and can't be translated (west is west anywhere). Both are 3 numbers but transform differently.

12
New cards

Homogeneous coordinates

Adding an extra component w to every point/vector: (x, y, z) -> (x, y, z, w), using 4x4 matrices in 3D. This lets translation be written as a matrix multiply, so all transformations share one representation.

13
New cards

Why homogeneous coordinates are needed

A matrix can only multiply and add, while translation adds a constant. The extra component of 1 multiplies the translation column so it gets added in. They're also used for the perspective divide.

14
New cards

w for points vs vectors

Points use w = 1, so translation applies. Vectors use w = 0, so the translation column is multiplied by 0 and vectors automatically ignore translation.

15
New cards

Converting homogeneous to Cartesian

Divide by w: (hx, hy, hz, h) -> (x, y, z). Example: (2,4,8,2) = (1,2,4). Basic transformations keep w = 1.

16
New cards

Vectors as points at infinity

Since vectors have w = 0, dividing by w is impossible, so a vector can be thought of as a point at infinity.

17
New cards

Combining (concatenating) transformations

Applying M then N gives x'' = N(Mx) = (NM)x. Multiply the matrices once, then do one matrix multiply per vertex instead of one per transformation.

18
New cards

Why combine transformations

Efficiency. With 1,000,000 vertices and 3 transforms you do 9M multiplications with one combined matrix instead of 27M doing them separately.

19
New cards

Order of transformations

Read right to left: the matrix closest to the point is applied first. In code, the transformation written last (just before drawing) is applied to the vertices first. A common source of bugs.

20
New cards

Matrix multiplication is not commutative

Order matters: rotate-then-translate gives a different result from translate-then-rotate.

21
New cards

Scale/rotate about a point P

Translate P to the origin, apply the scale/rotation, translate back: M = T(+P) * R * T(-P), read right to left. Needed because scale and rotation always work about the origin.

22
New cards

Two views of scale/rotation

Applied directly, scale/rotation transforms the whole world about the origin. To transform just one object, move it to the origin first, transform it, then move it back.

23
New cards

3D rotation requirements

You need three things: a rotation angle, a centre of rotation (handled with translation), and an axis of rotation.

24
New cards

Why 3D rotation is hard

You can rotate about any axis in 3D, and you can't build the matrix until you know the axis. Historically this caused lots of incorrect code.

25
New cards

Euler angles

Describing a rotation as three rotations about the x, y and z axes. The matrices are easy, but no ordering works for every rotation (Euler proved 3 numbers like this can't specify an arbitrary rotation).

26
New cards

Gimbal lock

With Euler angles, one rotation (e.g. 90 degrees about X) lines one axis up with another (Y onto Z), so a degree of freedom is lost and you can no longer rotate about the original axis.

27
New cards

Rotation matrix rows property

A rotation matrix rotates its own rows onto the x, y and z axes. Its rows are orthonormal unit vectors.

28
New cards

Inverse of a rotation matrix

Its transpose: R R^T = I, so R^-1 = R^T. Cheap to compute.

29
New cards

Building a rotation from 3 orthogonal vectors

Given orthonormal u, v, w, the matrix R with rows u, v, w rotates them onto x, y, z. R^T rotates x, y, z back onto u, v, w. The vectors must be unit length, so normalize first.

30
New cards

Rotation about an arbitrary axis a (idea)

Rotate a onto the z-axis, rotate by the angle about z, then undo the first rotation: M = R^T Rz(theta) R.

31
New cards

Arbitrary axis: building R

Normalize a (it's row 3). Pick t = a with its smallest-magnitude component set to 1 (so it's not collinear with a). u = (t x a)/|t x a|, v = a x u. R has rows u, v, a.

32
New cards

Arbitrary axis not through the origin

Wrap the rotation in translations: translate a point on the axis to the origin, rotate, translate back.

33
New cards

Transforming normal vectors (problem)

Transforming a normal by the same matrix M as the surface may leave it no longer perpendicular, because non-uniform scale doesn't preserve angles.

34
New cards

Normal transformation matrix

Use the inverse transpose of M: n' = (M^-1)^T n, then re-normalize it. In GLM: transpose(inverse(mat3(view*model))).

35
New cards

Why the inverse transpose works

Tangent t transforms as Mt. We need n'.(Mt) = 0 when n.t = 0. With n' = Ln this gives n^T L^T M t = 0, which holds if L^T M = I, so L = (M^-1)^T.

36
New cards

When M can transform normals directly

When M contains only rotations and translations (rigid-body transforms), because for a rotation (R^-1)^T = R. Any scaling needs the inverse transpose.

37
New cards

Normals and the projection matrix

Normals are transformed by view*model only, never by the projection matrix, since projecting a direction makes no sense.

38
New cards

Rigid-body transformation

A transformation that preserves shape, size and angles: only rotation and translation.

39
New cards

Affine transformation

A linear transformation plus translation (includes scale and shear). It doesn't necessarily preserve angles between lines.

40
New cards

Identity matrix

The "no transformation" matrix, glm::mat4(1.0). The usual starting point before applying transforms.

41
New cards

GLM rotation angle units

Radians, e.g. glm::rotate(matrix, angleRadians, axisVector).

42
New cards

Decomposing a transformation

Splitting a given matrix back into simple transforms: a translation (the last column), plus rotations and a scale. Use eigen-decomposition (R S R^T) if the upper block is symmetric, otherwise SVD (U S V).