SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş...

28
SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1

Transcript of SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş...

Page 1: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

1

SE 313 – Computer Graphics

Lecture 8: Transformations and Projections

Lecturer: Gazihan Alankuş

Page 2: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

2

Plan for Today

• Post-exam talk• Revisit transformations• Projections

Page 3: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

3

Exam Talk

• Go over exam questions

Page 4: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

4

Transformations (summary)

• Three types of linear transformations– Translation (point-vector addition)– Rotation (3x3 matrix multiplication)– Scale (vector-scalar multiplication)

Page 5: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

5

Transformations (summary)

• Three types of linear transformations– Translation (point-vector addition)– Rotation (3x3 matrix multiplication)– Scale (vector-scalar multiplication)

• Cannot combine these operations in one type of operation– Convert them to one type of operation (not

possible unless you use homogeneous coordinates)

Page 6: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

6

Transformations (summary)

• Homogeneous coordinates enable us to represent translation, rotation and scale using 4x4 matrix multiplications.

• This way we can combine them easily by multiplying matrices together. The resulting matrix is another transformation.

Page 7: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

7

Transformations (summary)

• 4x4 matrices that are combinations of translation, rotation and scale

0 0 0 1

Rotation and scale Translation

Page 8: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

8

Transformations (summary)

• You can read the local coordinate frame from 4x4 transformation matrices

0 0 0 1

Rotation and scale Translation

Where in the world the local frame’s origin is

The x, y and z axes of thelocal frame

Page 9: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

9

Transformations (summary)

• Intuitive understanding of transformations• Local-to-world: insert

new transformations near the wall (world)

• World-to-local: insert new transformations near the object

Page 10: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

10

Transformations (summary)

• Quaternions: data structure for rotation– Useful for animations

• Ways of representing rotations

Three angles (euler angles)

One axis, one angle 3x3 matrix

Quaternion

Best interpolation (slerp)Great-looking animations

Page 11: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

11

Plan for Today

• Post-exam talk• Revisit transformations• Projections

Page 12: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

12

Projection

• Projections from 3D to 2D– Taking pictures of the virtual world

[Images are borrowed from http://db-in.com]

Page 13: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

13

Projection Types

• Perspective projection– Just like our eyes and

cameras

• Orthographic projection– Architectural drawing

with no distance distortion

Page 14: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

14

Orthographic vs. Perspective Projection

[Images are borrowed from http://db-in.com]

Page 15: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

15

Orthographic Projection

• Get the 3D world, compress it on a 2D paper

[engineeringtraining.tpub.com]

Page 16: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

16

Orthographic Projection

• Great for isometric games (Starcraft, Diablo I-II)

• No depth sensation

Page 17: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

17

Orthographic Projection in Blender

• Select the camera• The viewport is defined

by the render output size• Camera has – Scale– Start and end clipping distances

Page 18: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

18

Perspective Projection

• Take the picture of the world from a single point

Page 19: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

19

Perspective Projection

• What parameters do I need?

Page 20: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

20

Perspective Projection

Page 21: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

21

Perspective Projection

• How do you do it mathematically?– Also using a 4x4 matrix

[songho.ca]

Page 22: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

22

Perspective Projection

• Let’s try to make sense of it very simply

0 0

0 0

0 0

0 0 -1 0

Translating in z

Output’s w depends on input’s zThe further it is in z, the smaller it will get

Page 23: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

23

Perspective Projection

• What that matrix does

Page 24: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

24

Perspective Projection in Blender

• Select the camera• The viewport is defined

by the render output size• Camera has – Field of view angle– Start and end clipping distances

Page 25: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

25

Perspective vs Orthographic Projection

Perspective

Orthographic

Fov=60◦, distance = 1

Fov=30◦, distance = 3

Fov=10◦, distance = 5

Fov=0◦, distance =

Page 26: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

26

Perspective vs Orthographic Projection

• Orthographic camera is a perspective camera where the camera is at the infinity and the field of view angle is zero

Page 27: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

27

Perspective vs Orthographic Projection

• In this transition, the size of the arrow in the image stays the same

• This is also "called the “dolly-zoom”, “Hitchcock zoom”, or “vertigo effect”

• Demonstration in Unity and sample scenes from movies

Page 28: SE 313 – Computer Graphics Lecture 8: Transformations and Projections Lecturer: Gazihan Alankuş 1.

28

For next week

• No homework• Study what we learned today, there will be a

quiz• Next week, a part of the lab will be about

projection