Khoa CNTT - DDHBK Hà nội
8682595
1
(c) SE/FIT/HUT 2002
1
B
ài 4
Các phép biến đổi Đồ hoạ
Affine Transformations
Le Tan Hung
Email:
I KHái niệm cơ bản
II Các phép biến đổi
III Hệ tọa độ đồng nhất
(c) SE/FIT/HUT 2002
2
Mô hình hoá - Modelling
Mô hình hoá là tiến trình tạo mới thao
tác trên các mô hình của các đối tượng
hay hệ thống
Computer graphics ~ quan tâm đến mô
tả hình học của các đối tượng nhằm
cung cấp phương pháp biểu diễn số cho
các hình trên cơ sở về kích thước và các
thuộc tính có liên quan đến tiến trình tô
trát
Các đối tượng hình học thường được
Phép biến đổi - Transformations
Trong kỹ thuật đồ hoạ 3 bước: modeling, rendering, displaying
Với Modeling:
Transformation: là phép ánh xạ tọa độ điểm hay vector thành tọa độ hay
vector khác
Biến đổi mô hình hoá - Modeling transformations
build complex models by positioning simple components
Biến đổitạo góc nhìn - Viewing transformations
placing virtual camera in the world
transformation from world coordinates to camera coordinates
Biến đổitạoHoạtcảnh - Animation
vary transformations over time to create motion
modeling
coordinate
Modeling
transformation
Viewing
transformation
world
coordinate
8682595
2
(c) SE/FIT/HUT 2002
7
Phép biến đổi Affine
Affine Transformations?
Ph
ép biến đổi
Affine l
àphépbiến đổitọa độ điểm đặctrưng
của đốitượng thành tậptương ứng các điểmmới để tạo ra các
hiệu ứng cho toàn đốitượng.
V
ídụ: phép biến đổitọa độ vớichỉ 2 điểm đầucuốicủa đoạn
thẳng tạo thành 2 điểmmới mà khi nối chúng vớinhautạothành
đoạnthẳng mới.
Các điểmnằmtrênđoạnthẳng sẽ có kếtquả là điểmnằmtrên
đoạnthẳng mớivới cùng phép biến đổi thông qua phép nội
suy.
(c) SE/FIT/HUT 2002
Phân loại - Transformations
Có 2 cách nhìn trên phép biến đổi
Object Transformation: thay
đổi tọa
độ của các điểm theo một số các
new values which specify point Q (Q
x
,Q
y
)
This can be expressed using some function T, that
maps co-ordinate pairs into co-ordinate pairs:
T(P
x
,P
y
) = (Q
x
,Q
y
)
or:
T(P) = Q
(c) SE/FIT/HUT 2002
Matrix Representation
If affine transformation T maps P onto Q, then Q is related to P as
follows:
=
⎟
⎟
⎠
⎞
⎜
⎜
⎝
⎛
y
x
y
x
y
x
t
t
P
P
dc
ba
Q
Q
xxxx
t bP aP Q ++=
yyyy
t dP cP Q ++=
Tr MP Q +=
(c) SE/FIT/HUT 2002
12
⎢
⎣
⎡
=
y
x
z
p
M
p
W
Khoa CNTT - DDHBK Hà nội
8682595
3
(c) SE/FIT/HUT 2002
13
Phép biến đổi
Phép bấtbiến
Phép biến đổitỉ lệ - Scaling
A scaling changes the size of an object with two scale factors, S
x
and S
y
Phép biếndạng
10
1
** yxdybx
b
yxTX =+=
⎥
⎦
⎤
⎢
⎣
⎡
=
x
z
y
(c) SE/FIT/HUT 2002
14
Phép quay- Rotation
x = ρ cos α, y = ρ sin α ;
x’ = ρ cos (θ +α ), y’ = ρ sin (θ +α )
;
x’ = ρ ( cosθ cosα - sinθ sinα )
= x cosθ -y sinθ
y’ = ρ ( sinθ cosα + cosθ sinα )
= x sinθ + y cosθ
[x' y']= [xcosθ -ysinθ xsinθ +
ycosθ]
y
( x, y )
x
We need only compute the image of the two endpoints of the original line
and then draw a straight line between them
Preservation of collinearity guarantees that polygons will transform into
polygons
Affine transformations map lines to lines;
(c) SE/FIT/HUT 2002
Thu
ộc tính
Preservation of parallelism
Preservation of parallelism guarantees that parallelograms will transform
into parallelograms
Preservation of proportional distances
Preservation of proportional distances means that mid-points of lines
remain mid-points
Affine transformations change volume by | Det(M) |;
(c) SE/FIT/HUT 2002
Kếthợp các phép biến đổi
Composition of Affine Transforms
Any affine transformation can be
decomposed into elementary
transformations.
Khoa CNTT - DDHBK Hà nội
8682595
4
(c) SE/FIT/HUT 2002
19
Thuộc tính
T
ác động lên tập các điểm đặc trưng của đối tượng tạo thành
phép biến đổi cho đối tượng
We have defined each transformation by their effects on single points
In practice these will be applied to multiple points to transfer entire scenes
or objects made up of many defining points
T
(c) SE/FIT/HUT 2002
Điểm gốc - Pivotal points
Cho phép quay và tỉ lệ Rotation and Scaling
The simple versions of rotation and scaling have been based around the origin.
This means that when we rotate or scale, the object will also move, with
respect to the origin
Translate all points through (-c1,-c2)
Rotate all points about the origin by
Vấn đề gặp phải:
An affine transformation is composed of a linear transformation
followed by a translation
Unfortunately, the translation portion is not a matrix
multiplication but must instead be added as an extra term, or
vector
What we need is a “trick”, so that translations can be represented
in matrix multiplication form
This then means that they can be easily composed with other
transformations, by simply multiplying the matrices together
(c) SE/FIT/HUT 2002
23
Tọa độ đồng nhất
Homogeneous Transform
x' = ax + by + n
y' = bx + dy + m
Phương pháp biểudiễnmở rộng thông qua tọa độ đồng
nhấtcủa các vector vị trí
Với ứng dụng của phép chiếuhìnhhọcmàởđótọa độ
điểm đượcmôtả dướima trận[ x* y* h]
với x = x*/h, y = y*/h, z = z*/h và h là mộtsố thựctuỳ ý
Phép tịnh tiến
⎥
⎥
⎥
⎦
⎤
⎢
⎢
⎢
⎣
⎡
=
1
0
0
][
nm
dc
ba
T
]1[
1
010
001
]1[]1''[ nymx
nm
yxyx ++=
⎥
⎥
⎤
⎢
⎢
⎢
⎣
⎡
=
(c) SE/FIT/HUT 2002
27
Phép quay
y
( x, y )
x
α
ρ
θ
ρ
( x’, y’ )
⎥
⎥
⎥
⎦
⎤
⎢
⎢
⎢
⎣
⎡
−=
100