CMSC427 Transformations I Credit: slides 9+ from Prof. Zwicker - - PowerPoint PPT Presentation

β–Ά
cmsc427 transformations i
SMART_READER_LITE
LIVE PREVIEW

CMSC427 Transformations I Credit: slides 9+ from Prof. Zwicker - - PowerPoint PPT Presentation

CMSC427 Transformations I Credit: slides 9+ from Prof. Zwicker Transformations: outline Types of transformations Specific: translation, rotation, scaling, shearing Classes: rigid, affine, projective Representing transformations


slide-1
SLIDE 1

CMSC427 Transformations I

Credit: slides 9+ from Prof. Zwicker

slide-2
SLIDE 2
  • Types of transformations
  • Specific: translation, rotation, scaling, shearing
  • Classes: rigid, affine, projective
  • Representing transformations
  • Unifying representation with homogeneous coordinates
  • Transformations represented as matrices
  • Composing transformations
  • Sequencing matrices
  • Sequencing using OpenGL stack model
  • Transformation examples
  • Rotating or scaling about a point
  • Rotating to a new coordinate frame
  • Applications
  • Modeling transformations (NOW)
  • Viewing transformations (LATER)

Transformations: outline

slide-3
SLIDE 3
  • Create instance of
  • bject in object

coordinate space

  • Create circle at origin
  • Transform object to

world coordinate space

  • Scale by 1.5
  • Move down by 2 unit
  • Do so for other objects
  • Two rects make hat
  • Three circles make body
  • Two lines make arms
  • Object coordinate

space

  • World coordinate space

Modeling with transformations

slide-4
SLIDE 4
  • Rigid
  • Translate, rotate,

uniform scale

  • No distortion to object
  • Affine
  • Translate, rotate, scale

(non-uniform), shear, reflect

  • Limited distortions
  • Preserve parallel lines

Classes of transformations

slide-5
SLIDE 5
  • Affine
  • Preserves parallel lines
  • Projective
  • Foreshortens
  • Lines converge
  • For viewing/rendering

Classes of transformations

slide-6
SLIDE 6
  • Affine
  • Reshape, size object
  • Rigid
  • Place, move object
  • Projective
  • View object
  • Later …
  • Non-linear, arbitrary
  • Twists, pinches, pulls
  • Not in this unit

Classes of transformations: summary

slide-7
SLIDE 7
  • Scale a point p by s and

translate by T

  • Vector multiplication and

addition

  • Repeat and we get
  • Gets unwieldy
  • Instead – unify notation

with homogeneous coordinates and matrices First try: scale and rotate vertices in vector notation

π‘Ÿ = 𝑑 βˆ— π‘ž + π‘ˆ

T p q

π‘Ÿ = 𝑑( 𝑑 βˆ— π‘ž + π‘ˆ + π‘ˆ( π‘Ÿ = 2 βˆ— 2,3 +< 2,2 > π‘Ÿ = (6,8)

slide-8
SLIDE 8

Matrix practice 𝑁 = 2 2 𝑆 = 1 1 3 𝑄 = 2 3 𝑁𝑆 = 2 2 1 1 3 = 𝑆𝑁 = 1 1 3 2 2 = 𝑁𝑄 = 2 2 2 3 =

slide-9
SLIDE 9

Matrix practice 𝑁 = 2 1 2 𝑆 = 1 1 3 𝑄 = 2 3 𝑁𝑆 = 2 1 2 1 1 3 = 2 7 1 6 𝑆𝑁 = 1 1 3 2 1 2 = 3 2 3 6 𝑁𝑄 = 2 1 2 2 3 = 4 8

slide-10
SLIDE 10

Matrix transpose and column vectors 𝑄 = 2 3 = 2 3 9 𝑆9 = 1 1 3

9

= 𝐼9 = 2 1 3 4 1 5

9

=

slide-11
SLIDE 11

Matrix transpose and column vectors 𝑄 = 2 3 = 2 3 9 𝑆9 = 1 1 3

9

= 1 1 3 𝐼9 = 2 1 3 4 1 5

9

= 2 4 1 1 3 5

slide-12
SLIDE 12

Matrices Abstract point of view

  • Mathematical objects with set of operations
  • Addition, subtraction, multiplication, multiplicative

inverse, etc.

  • Similar to integers, real numbers, etc.

But

  • Properties of operations are different
  • E.g., multiplication is not commutative
  • Represent different intuitive concepts
  • Scalar numbers represent distances
  • Matrices can represent coordinate systems, rigid

motions, in 3D and higher dimensions, etc.

12

slide-13
SLIDE 13

Matrices Practical point of view

  • Rectangular array of numbers
  • Square matrix if
  • In graphics often

13

slide-14
SLIDE 14

Matrix addition

14

slide-15
SLIDE 15

Multiplication with scalar

15

slide-16
SLIDE 16

Matrix multiplication

16

slide-17
SLIDE 17

Matrix multiplication

17

slide-18
SLIDE 18

Matrix multiplication

18

slide-19
SLIDE 19

Matrix multiplication

19

slide-20
SLIDE 20

Matrix multiplication Special case: matrix-vector multiplication

20

slide-21
SLIDE 21

Linearity

  • Distributive law holds

i.e., matrix multiplication is linear

http://en.wikipedia.org/wiki/Linear_map

  • But multiplication is not commutative,

in general

21

slide-22
SLIDE 22

Identity matrix

22

slide-23
SLIDE 23

Matrix inverse Definition If a square matrix is non-singular, there exists a unique inverse such that

  • Note
  • Computation
  • Gaussian elimination, Cramer’s rule (OctaveOnline)
  • Review in your linear algebra book, or quick summary

http://www.maths.surrey.ac.uk/explore/emmaspages/option1.html

23

slide-24
SLIDE 24

Java vs. OpenGL matrices

  • OpenGL (underlying 3D graphics API used in the

Java code, more later)

http://en.wikipedia.org/wiki/OpenGL

  • Matrix elements stored in

array of floats float M[16];

  • β€œColumn major” ordering
  • Java base code
  • β€œRow major” indexing
  • Conversion from

Java to OpenGL convention hidden somewhere in basecode!

24

slide-25
SLIDE 25

T

  • day

Transformations & matrices

  • Introduction
  • Matrices
  • Homogeneous coordinates
  • Affine transformations
  • Concatenating transformations
  • Change of coordinates
  • Common coordinate systems

25

slide-26
SLIDE 26

Vectors & coordinate systems

  • Vectors defined by orientation, length
  • Describe using three basis vectors

26

slide-27
SLIDE 27

Points in 3D

  • How do we represent 3D points?
  • Are three basis vectors enough to define the location of

a point?

27

slide-28
SLIDE 28

Points in 3D

  • Describe using three basis vectors and reference point,
  • rigin

28

slide-29
SLIDE 29

Vectors vs. points

  • Vectors
  • Points
  • Representation of vectors and points using 4th coordinate is

called homogeneous coordinates

29

slide-30
SLIDE 30

Homogeneous coordinates

  • Represent an affine space

http://en.wikipedia.org/wiki/Affine_space

  • Intuitive definition
  • Affine spaces consist of a vector space and a set of

points

  • There is a subtraction operation that takes two points

and returns a vector

  • Axiom I: for any point a and vector v, there exists point

b, such that (b-a) = v

  • Axiom II: for any points a, b, c we have

(b-a)+(c-b) = c-a

30

slide-31
SLIDE 31

Affine space

Vector space,

http://en.wikipedia.org/wiki/Vector_space

  • [xyz] coordinates
  • represents vectors

Affine space

http://en.wikipedia.org/wiki/Affine_space

  • [xyz1], [xyz0]

homogeneous coordinates

  • distinguishes points

and vectors

31

slide-32
SLIDE 32

Homogeneous coordinates

  • Subtraction of two points yields a vector
  • Using homogeneous coordinates

32

slide-33
SLIDE 33

T

  • day

Transformations & matrices

  • Introduction
  • Matrices
  • Homogeneous coordinates
  • Affine transformations
  • Concatenating transformations
  • Change of coordinates
  • Common coordinate systems

33

slide-34
SLIDE 34

Affine transformations

  • Transformation, or mapping: function that maps

each 3D point to a new 3D point β€žf: R3 -> R3β€œ

  • Affine transformations: class of transformations to

position 3D objects in space

  • Affine transformations include
  • Rigid transformations
  • Rotation
  • Translation
  • Non-rigid transformations
  • Scaling
  • Shearing

34

slide-35
SLIDE 35

Affine transformations

  • Definition: mappings that preserve colinearity and

ratios of distances

http://en.wikipedia.org/wiki/Affine_transformation

  • Straight lines are preserved
  • Parallel lines are preserved
  • Linear transformations + translation
  • Nice: All desired transformations (translation,

rotation) implemented using homogeneous coordinates and matrix-vector multiplication

35

slide-36
SLIDE 36

Translation

Point Vector

36

slide-37
SLIDE 37

Matrix formulation

Point Vector

37

slide-38
SLIDE 38

Matrix formulation

  • Inverse translation
  • Verify that

38

slide-39
SLIDE 39

Note

  • What happens when you translate a vector?

39

slide-40
SLIDE 40

Rotation First: rotating a vector in 2D

  • Convention: positive angle rotates

counterclockwise

  • Express using rotation matrix

40

slide-41
SLIDE 41

Rotating a vector in 2D

41

slide-42
SLIDE 42

Rotating a vector in 2D

42

slide-43
SLIDE 43

Rotating a vector in 2D

43

slide-44
SLIDE 44

Rotation in 3D Rotation around z-axis

  • z-coordinate does not change
  • What is the matrix for ?

v0= R z(Β΅)v

44

slide-45
SLIDE 45

Other coordinate axes

  • Same matrix to rotate points and vectors
  • Points are rotated around origin

45

slide-46
SLIDE 46

Rotation in 3D

  • Concatenate rotations around x,y,z axes to obtain

rotation around arbitrary axes through origin

  • are called Euler angles

http://en.wikipedia.org/wiki/Euler_angles

  • Disadvantage: result depends on order!

46

Gimbal

https://en.wikipedia.org/wiki/Gimbal

slide-47
SLIDE 47

Rotation around arbitrary axis

  • Still: origin does not change
  • Counterclockwise rotation
  • Angle , unit axis
  • Intuitive derivation see

http://mathworld.wolfram.com/RotationFormula.html

47

slide-48
SLIDE 48

Summary

  • Different ways to describe rotations mathematically
  • Sequence of rotations around three axes (Euler angles)
  • Rotation around arbitrary angles (axis-angle

representation)

  • Other options exist (quaternions, etc.)
  • Rotations preserve
  • Angles
  • Lengths
  • Handedness of coordinate system
  • Rigid transforms
  • Rotations and translations

48

slide-49
SLIDE 49

Rotation matrices

  • Orthonormal
  • Rows, columns are unit length and orthogonal
  • Inverse of rotation matrix?

49

slide-50
SLIDE 50

Rotation matrices

  • Orthonormal
  • Rows, columns are unit length and orthogonal
  • Inverse of rotation matrix?
  • Its transpose

50

slide-51
SLIDE 51

Rotations

  • Given a rotation matrix
  • How do we obtain

?

51

slide-52
SLIDE 52

Rotations

  • Given a rotation matrix
  • How do we obtain

?

52

slide-53
SLIDE 53

Rotations

  • Given a rotation matrix
  • How do we obtain

?

  • How do we obtain

…?

53

slide-54
SLIDE 54

Rotations

  • Given a rotation matrix
  • How do we obtain

?

  • How do we obtain

…?

54

slide-55
SLIDE 55

Scaling

  • Origin does not change

55

slide-56
SLIDE 56

Scaling

  • Inverse scaling?

56

slide-57
SLIDE 57

Scaling

  • Inverse scaling?

57

slide-58
SLIDE 58

Shear

  • Pure shear if only one parameter is non-zero
  • Cartoon-like effects

58

slide-59
SLIDE 59

Summary affine transformations

  • Linear transformations (rotation, scale, shear,

reflection) + translation

Vector space,

http://en.wikipedia.org/wiki/Vector_space

  • vectors as [xyz]

coordinates

  • represents vectors
  • linear transformations

Affine space

http://en.wikipedia.org/wiki/Affine_space

  • points and vectors

as [xyz1], [xyz0] homogeneous coordinates

  • distinguishes points

and vectors

  • linear tranforms and

translation

59

slide-60
SLIDE 60

Summary affine transformations

  • Implemented using 4x4 matrices, homogeneous

coordinates

  • Last row of 4x4 matrix is always [0 0 0 1]
  • Any such matrix represents an affine

transformation in 3D

  • Factorization into scale, shear, rotation, etc. is

always possible, but non-trivial

  • Polar decomposition

http://en.wikipedia.org/wiki/Polar_decomposition

60

slide-61
SLIDE 61

T

  • day

Transformations & matrices

  • Introduction
  • Matrices
  • Homogeneous coordinates
  • Affine transformations
  • Concatenating transformations
  • Change of coordinates
  • Common coordinate systems

61

slide-62
SLIDE 62

Concatenating transformations

  • Build β€œchains” of transformations
  • Apply followed by followed by
  • Overall transformation

is an affine transformation

  • Multiplication on the left

62

slide-63
SLIDE 63

Concatenating transformations

  • Result depends on order because matrix

multiplication not commutative

  • Thought experiment
  • Translation followed by rotation vs. rotation followed by

translation

63

slide-64
SLIDE 64

Rotating with pivot Rotation around

  • rigin

Rotation with pivot

64

slide-65
SLIDE 65
  • 1. Translation
  • 2. Rotation
  • 3. Translation

Rotating with pivot

65

slide-66
SLIDE 66

Rotating with pivot

  • 1. Translation
  • 2. Rotation
  • 3. Translation

66

slide-67
SLIDE 67

Concatenating transformations

  • Arbitrary sequence of transformations
  • Note: associativity

So either is valid T=M3.multiply(M2); Mtotal=T.multiply(M1)

  • r

T=M2.multiply(M1); Mtotal=M3.multiply(T)

67

slide-68
SLIDE 68
  • Transformations are used for modeling
  • Classes of transformation: rigid and affine
  • Why we use homo. coordinates and matrices
  • How to do matrix mults, inversion, transpose
  • Homogenous coordinates, vectors vs. points
  • Properties of affine transformations
  • Transforms: translation, scale, rotation, shear
  • Only starting with 3D rotations – don’t be concerned
  • Order of transformations
  • They don’t commute, but are associative
  • Translate to origin for scaling, rotation

Transformation: summary