1 of 47

Nima Kalantari

CSCE 441 - Computer Graphics

Transformations 2D

Some slides from Ren Ng and Ravi Ramamoorthi

2 of 47

Why study transforms?

3 of 47

Projecting from 3D to 2D

Model from Pradeep Sen

Camera

COP

Image Plane

3D

2D

4 of 47

Modeling A Robot Army

  • Can describe position of object instances

iRobot movie

5 of 47

Posing a Character’s Skeleton

  • Can describe relative position of connected body parts

iRobot movie

6 of 47

What Are Transforms?

  • Just functions acting on points

  • Linear transforms
    • Condition:

7 of 47

Outline

  • Basic transformations
  • Composing transformations

8 of 47

Scale Transform (Uniform)

S0.5

9 of 47

Scale Matrix (Uniform)

S0.5

10 of 47

Scale (Non-Uniform)

S0.5,1.0

11 of 47

Is scale a linear transform?

12 of 47

Reflection

13 of 47

Reflection Matrix

14 of 47

Shear Matrix

15 of 47

Rotation Matrix

16 of 47

2-D Rotation

17 of 47

2-D Rotation

Trigonometric Identity

Substitute

18 of 47

Rotation Matrix

19 of 47

Rotation Matrix

20 of 47

Rotation Matrix

21 of 47

Rotation Matrix

22 of 47

Linear Transforms = Matrices

23 of 47

24 of 47

Translation?

T1,1

25 of 47

Translation

  • E.g., move x by +5 units, leave y
  • We need appropriate matrix. What is it?

Transformations game demo

26 of 47

Add an auxiliary dimension

27 of 47

Add an auxiliary dimension

28 of 47

Homogeneous Coordinates

  • Represent an n-dimensional Euclidean point using an n+1 dimensional point
  • For points: set dimension n+1 (w) to 1
    • E.g., 2D Euclidean -> 3D Homogeneous

Euclidean

Homogeneous

29 of 47

Homogeneous Coordinates

  • For points: to go from homogeneous coordinate to Euclidean
    • Divide by the last coordinate
    • Remove the normalized last coordinate

Euclidean

Homogeneous

30 of 47

Homogeneous Coordinates

  • Multiplication by scalar has no effect

Euclidean

Homogeneous

=

=

31 of 47

Homogeneous coordinates: some intuition

x

y

w = 1

w

32 of 47

Homogeneous coordinates: points vs. vectors

w

w = 1

x

y

33 of 47

Homogeneous coordinates (vectors)

  • To go to homogeneous, set the last dimension to 0
  • To come back to Euclidean, remove the last dimension

Euclidean

Homogeneous

34 of 47

General Translation Matrix

  • Point

  • Vector

35 of 47

Homogeneous coordinates

  • They are useful for two types of transformations
    • Translation
    • Projection (discussed later)

36 of 47

Advantages of Homogeneous Coords

  • Unified framework for translation, rotation, etc.
  • Can concatenate any set of transforms to 3x3 matrix (4x4 for 3D)
  • Simpler formulas, no special cases
  • Standard in graphics software, hardware

37 of 47

2D Transformations

  • Scale
  • Rotation
  • Translation

38 of 47

Outline

  • Basic transformations
  • Composing transformations

39 of 47

Composite Transform

?

40 of 47

Rotate Then Translate

41 of 47

Translate Then Rotate?

42 of 47

Ordering matters!

43 of 47

Ordering matters!

  • Matrix multiplication is not commutative

  • Recall the matrix math represented by these symbols:

  • Note that matrices are applied right to left:

44 of 47

Composing Transforms

  • Sequence of transforms A1, A2, A3, ...
    • Compose by matrix multiplication
      • Very important for performance!

Pre-multiply n matrices to obtain a �single matrix representing combined transform

45 of 47

Decomposing Complex Transforms

  • How to rotate around a given point c?
    • Translate center to origin
    • Rotate
    • Translate back
  • Matrix representation?

46 of 47

Affine Transformations

  • Affine map = linear map + translation
  • Using homogenous coordinates:

47 of 47

Inverse Transform

  • is the inverse of in both a matrix and geometric sense