Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @...

28
Graphics Graphics Lab @ Korea University http://kucg.korea.ac.kr Geometric Transformations Korea Univ. Computer Graphics Lab.

Transcript of Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @...

Page 1: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

Graphics

Graphics Lab @ Korea University http://kucg.korea.ac.kr

Geometric

Transformations

Korea Univ.

Computer Graphics Lab.

Page 2: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Geometric Transformations

Translation

Scaling

Rotation

etc.

http://kucg.korea.ac.kr

Page 3: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Geometric Transformations’ Role

Positioning

Deformation

Animation

Camera Control

etc.

http://kucg.korea.ac.kr

Page 4: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

3D Translation

11000

100

010

001

1

'

'

'

z

y

x

t

t

t

z

y

x

z

y

x

x

z

y

zyx tzztyytxx ' ,' ,'

T(tx, ty, tz)

http://kucg.korea.ac.kr

Page 5: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

3D Scaling

11000

000

000

000

1

'

'

'

z

y

x

s

s

s

z

y

x

z

y

x

x

z

y

zyx szzsyysxx ' ,' ,'

http://kucg.korea.ac.kr

Page 6: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Fixed-point Scaling

11000

100

010

001

1000

000

000

000

1000

100

010

001

1

'

'

'

),,( ),,( ),,(z

y

x

z

y

x

s

s

s

z

y

x

z

y

x

zyxTsssSzyxTf

f

f

z

y

x

f

f

f

fffzyxfff

x z

y

Original Position Translation Scaling Inverse Translation

x z

y

x z

y

x z

y

F

http://kucg.korea.ac.kr

Page 7: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

3D Rotations

Rotations about Basic Coordinate Axes

x-axis rotation

y-axis rotation

z-axis rotation

General 3D Rotations

About an axis parallel to one of basic coordinate axes

About an arbitrary axis

http://kucg.korea.ac.kr

Page 8: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Order of Rotations

http://kucg.korea.ac.kr

Page 9: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Rotations about Basic Coordinate Axes

11000

0100

00cossin

00sincos

1

'

'

'

z

y

x

z

y

x

11000

0cossin0

0sincos0

0001

1

'

'

'

z

y

x

z

y

x

11000

0cos0sin

0010

0sin0cos

1

'

'

'

z

y

x

z

y

x

z

y

x

z

y

x

z

y

x

z-axis Rotation x-axis Rotation y-axis Rotation

http://kucg.korea.ac.kr

Page 10: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Homogeneous Coordinate

4th coordinate in 3D means

In Mathematics

The size of basic step of the coordinate system

ex) (1, 2, 3, 1) = (2, 4, 6, 2)

In Graphics

Translation matrix into the multiplication scheme

http://kucg.korea.ac.kr

Page 11: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Homogeneous Coordinate in

Graphics

Translation matrix is integrated into the

multiplication scheme

Provides computational efficiency

ex) a complex object with millions of vertices

To be scaled, rotated, and translated

Two possible choices

Applying 3 transformation matrices to every vertex

Applying just a pre-computed composite matrix

Careful with the order,

http://kucg.korea.ac.kr

Page 12: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

General 3D Rotation Type 1

About an axis parallel to one of basic coordinate axes

http://kucg.korea.ac.kr

Page 13: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

General 3D Rotation Type 2

About an Arbitrary Axis

(x2, y2, z2)

(x1, y1, z1)

x

y

RA-1

T-1

RA

T

R

z

Translate (x1, y1, z1) to the origin

Rotate (x2’, y2’, z2’) on to the z axis

Rotate the object around the z-axis

Rotate the axis to the original orientation

Translate the rotation axis to the original position

http://kucg.korea.ac.kr

Page 14: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Arbitrary Axis Rotation Process(1/5)

Step 1. Translate the Tail Vertex to the Origin

1000

100

010

001

1

1

1

z

y

x

T

x

y

z

(x2, y2, z2)

(x1, y1, z1)

http://kucg.korea.ac.kr

Page 15: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Arbitrary Axis Rotation Process(2/5)

Step 2. Rotate about x Axis by α

1000

0//0

0//0

0001

1000

0cossin0

0sincos0

0001

dcdb

dbdcx

R

d

c

cb

c

d

b

cb

b

22

22

cos

sin(a, b, c)

(0, b, c)

Projected

Point

Rotated

Point

x

y

z

121212 , , zzcyybxxa

http://kucg.korea.ac.kr

Page 16: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Arbitrary Axis Rotation Process(3/5)

Step 3. Rotate about y axis clockwisely by β

Counterclockwisely by -β

l

d

l

a

dacbal

cos ,sin

222222

1000

0/0/

0010

0/0/

1000

0cos0sin

0010

0sin0cos

1000

0cos0sin

0010

0sin0cos

ldla

lald

y

R

Projected

Point

Rotated

Point

d

(a,0,d)

x

y

z

http://kucg.korea.ac.kr

Page 17: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Arbitrary Axis Rotation Process(4/5)

Step 4. Rotate about z Axis by

1000

0100

00cossin

00sincos

zRx

y

z

http://kucg.korea.ac.kr

Page 18: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Arbitrary Axis Rotation Process(5/5)

Step 5. Reverse Transformation

To place the axis back in its initial position

1000

0cos0sin

0010

0sin0cos

1000

0cossin0

0sincos0

0001

1000

100

010

001

1

1

1

111

z

y

x

yx RRT

x

y

z

l

l

TRRRRRTR )()()()()()( 111 xyzyx

http://kucg.korea.ac.kr

Page 19: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Characteristics of the Rotation Matrix

Orthogonal

Each row vectors are perpendicular

Each column vectors are perpendicular

Orthonormal = Orthogonal + …

Each row vector is a unit vector

Each column vector is a unit vector

All rotation matrices should be “orthonormal”

Inverse of Orthonormal Matrix

The transpose of the original matrix

TRR 1

http://kucg.korea.ac.kr

Page 20: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Other Transformations

Reflection to the xy Plane

z-axis Shear

x z

y

11000

0100

0010

0001

1

'

'

'

z

y

x

z

y

x

x z

y

(a, b, c) (a, b, -c)

11000

0100

010

001

1

'

'

'

z

y

x

b

a

z

y

x

http://kucg.korea.ac.kr

Page 21: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

3D Transformation Summary

General Transformation Matrix

4x4 square matrix

1141

1333

000 S

LIFC

KHEB

JGDA Scaling, Reflection,

Shearing, Rotation Translation

http://kucg.korea.ac.kr

Page 22: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

Graphics

Graphics Lab @ Korea University

Arbitrary Axis Rotation

Example

http://kucg.korea.ac.kr

Page 23: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Goal

Find the rotation matrix that rotates 90º about

an axis by its endpoints A(2, 1, 0) and B(3, 3, 1)

Works to Do

Translate the point A to the origin

T(-2, -1, 0)

Adjust the axis AB to one of the coordinate axes

Rotate 90º

Reverse all the transformations

http://kucg.korea.ac.kr

Page 24: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Step 1

Translate tail point A to the origin

T(-2, -1, 0)

1000

0100

1010

2001

Tx

z

y

A’(0, 0, 0)

B’(1, 2, 1)

http://kucg.korea.ac.kr

Page 25: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Step 2

Rotate axis A’B’ about the x axis by

Until it lies on the xz plane

1000

05

5

5

520

05

52

5

50

0001

xR

6121,5

5

5

1cos,

5

52

5

2

12

2sin 222

22

l

x

z

y

l

(0, 2, 1)

B”(1, 0, )

B’(1, 2, 1)

5

http://kucg.korea.ac.kr

Page 26: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Step 3

Rotate axis A’B’’ about the y axis by β

Until it coincides with the z axis

x

z

y

1000

06

300

6

6

0010

06

60

6

30

yR

6

30

6

5cos,

6

6

6

1sin

(0, 0, )

l

B”(1, 0, ) 56

http://kucg.korea.ac.kr

Page 27: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Step 4

Rotate 90° about the z axis

1000

0100

0001

0010

90zz RR

TRRRRRTR xyzyx 111

http://kucg.korea.ac.kr

Page 28: Geometric Transformationskucg.korea.ac.kr/.../tutor/04GeometricTransformation.pdfKUCG Graphics Lab @ Korea University Homogeneous Coordinate in Graphics Translation matrix is integrated

KUCG

Graphics Lab @ Korea University

Final Result

1000

558.0167.0741.0650.0

149.1075.0667.0741.0

742.1983.0075.0167.0

1000

0100

1010

2001

1000

05

5

5

520

05

52

5

50

0001

1000

06

300

6

6

0010

06

60

6

30

1000

0100

0001

0010

1000

06

300

6

6

0010

06

60

6

30

1000

05

5

5

520

05

52

5

50

0001

1000

0100

1010

2001

R

477.530

449.26

236.25

http://kucg.korea.ac.kr