1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Lecture computer graphics and virtual reality slides lesson 5 modeling transformation

48 0 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Modeling Transformation
Tác giả Trinh Thanh Trung
Trường học School of ICT, HUST
Định dạng
Số trang 48
Dung lượng 1,15 MB

Nội dung

Trang 4 Transformation Definition■ What is a transformation?□ P′=TP□Transform the coordinates / normal vectors of objects■ Uses□Moving the objects to the desired location in the environm

Trang 1

Lesson 5

Modeling Transformation

Trinh Thanh Trung School of ICT, HUST

Trang 3

Transformation

Trang 4

□ Virtual camera: parallel and perspective projections

Trang 5

Types of transformation

Object Transformation alters the coordinates of

each point according to some rule, leaving the

underlying coordinate system unchanged

Coordinate Transformation produces a

different coordinate system, and then represents all original points in this new system

Trang 6

Display

Coordinate System

MODELING

TRANSFORMS

Projection Coordinate System

PROJECTION

TRANSFORMS

Trang 7

Modeling

Transformation

Trang 8

Transformation

Trang 9

Transformation

Trang 10

Affine transformation

■ Whole collections of points may be transformed

by the same transformation T, e.g lines or circles

■ The image of a line, L, under T, is the set of all images of the individual points of L

■ For most mappings of interest, this image is still

a connected curve of some shape

■ For some mappings, the result of transforming a line may no longer be a line

lines, and are the most commonly-used

transformations in computer graphics

Trang 11

Affine transformation properties

endpoints of the original line and then draw a

straight line between them

Trang 12

Affine transformation properties

■ Preservation of proportional distances

Trang 14

2D transformations

Trang 15

Matrix representation

■ All affine transformations in 2D can be

generically described in terms of a generic equation

P d

c

b a

Q Q

Trang 16

■ A translation moves an object into a different position in a scene

Note: House shifts position relative to origin

y

x

0 1

Trang 17

x y

x

t

t P

P Q

t T

y

x P

Transformation matrix

Trang 18

■ Scaling multiplies all coordinates

□ Alters the size of an object

Note: House shifts position relative to origin

y

x

0 1

Trang 19

x P

x x

y

x

S P

S P

Q Q

Trang 20

x = r cos , y = r sin  x’ = r cos ( + ), y’ = r sin ( + ) x’ = r ( cos cos - sin sin )

Trang 21

Rotates all coordinates by a specified angle

x new = x old × cosθ – y old × sinθ

y new = x old × sinθ + y old × cosθ

Trang 22

■ Using the trigonometric relations, a point

rotated by an angle q about the origin is given by the following equations:

y

x P

sincos

y x

y x

y

x

P P

P P

Q Q

Trang 23

■ A shearing affects an object in a particular

direction (in 2D, it’s either in the x or in the y

Trang 24

A shear in the x direction would be as follows:

■ More generally: a simultaneous shear in both the

x and y directions would be

y

x

P

hP P

Q Q

y x

y

x

gP P

hP P

Q Q

Trang 25

x y

x

t

t P

P Q

Q

10

01

sin

sincos

y

x y

x

P

P θ θ

θ θ

1

y

x y

x

P

P g

h Q

Trang 26

Homogenous representation

Trang 27

■ An affine transformation is composed of a linear

combination followed by a translation

■ Unfortunately, the translation portion is not a

matrix multiplication but must instead be added as

an extra term, or vector – this is inconvenient

□ E.g pivotal point rotation

Trang 28

R (  ) ( − , − ) T ( dx , dy ) R (  ) T ( − dx , − dy ) H

Trang 29

Homogeneous Coordinates

A point (x, y) can be re-written in homogeneous

coordinates as (xh, yh, h)

The homogeneous parameter h is a

non-zero value such that:

■ We can then write any point (x, y) as (h.x, h.y, h)

■ We can conveniently choose h = 1 so that

y = h

Trang 30

Why use homogeneous coordinates

■ Allow scaling factors to be removed from

equations

■ All of the transformations we discussed

previously can be represented as 3*3 matrices

■ Allows us use matrix multiplication to calculate transformations

Trang 31

Homogeneous Coordinates

1 to both P and Q, and also a third row and column to M, consisting of zeros and a 1

y

x y

x y

x

P

P t

d c

t b a Q

1 0

0 1

y

x

t

t M

0 0

0 0

y

x

S

S M

0

0 cos sin

sin cos

0 1

0 1

g

h M

Translation by {tx, ty}

Scale by Sx, Sy Shear by g, h:

Rotate by :

Trang 32

Homogeneous Translation

The translation of a point by (dx, dy) can be

written in matrix form as:

0

1 0

0 1

dy dx

+ +

* 1

* 0

* 0

1

*

* 1

* 0

1

*

* 0

* 1

1 1

0 0

1 0

0 1

dy y

dx x

y x

dy y

x

dx y

x y

x dy

dx

Trang 33

Homogenous Coordinates

■ To make operations easier, 2-D points are

written as homogenous coordinate column vectors

100

00

00

y s

x s y

x s

s

y

x y

sin cos

1 1

0 0

0 cos

sin

0 sin

cos

y x

y x

Trang 35

R (  ) ( − , − ) T ( dx , dy ) R (  ) T ( − dx , − dy ) H

Trang 36

0 0

1 0

0 1

1 0

0

0 cos

sin

0 sin

cos

1 0

dx dy

REMEMBER: Matrix multiplication is NOT

commutative so order matters

v dy dx

T R

dy dx

T

Trang 37

Scale → Translate

Translate → Scale

Trang 38

3D transformations

Trang 39

Homogenous coordinates

■ Point representation in 3D

■ Homogenous transformation matrix

■ We are still able to use P’ = R.P

0 0

z y x

d j

h g

d f

e d

d c

b a

P P P

Trang 40

0 0

1 0 0

0 1 0

0 0 1

z y x

d d d

1 0

0 0

1 0 0

0 1 0

0 0 1

z y x

z y x

d z

d y

d x

z y x

d d d

Trang 41

0 0

0 0

0

0 0

0

0 0

0

z y

x

S S

1 0

0 0

0 0

0

0 0

0

0 0

0

z S

y S

x S

z y x

S S

S

z y x

z y

x

Trang 42

down to the coordinate center

x y

z

x y

z

x y

z

Trang 43

Every rotation around the origin can be decomposed into a rotation around the x- axis followed by a rotation around the y-axis followed by

a rotation around the z-axis.

Euler’s Theorem

Trang 44

0 0

0 cos

sin 0

0 sin

cos 0

0 0

0 1

0

0 1 0

0

0 0 cos

sin

0 0 sin

Trang 45

0 0

0 cos

0 sin

0 0

1 0

0 sin

0 cos

Trang 47

Any questions?

Trang 48

Lecture notes provided by School of Information and

Communication Technology, Hanoi University of Science and

Technology.

Composed by Huynh Quyet Thang, Le Tan Hung, Trinh Thanh

Trung and others

Edited by Trinh Thanh Trung

Special thanks to all the people who made and released these awesome resources for free:

■ Presentation template by SlidesCarnival

■ Photographs by Death to the Stock Photo ( license )

■ Diverse device hand photos by Facebook Design Resources

Ngày đăng: 02/03/2024, 13:59

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN