Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
-
Upload
shannon-paul -
Category
Documents
-
view
215 -
download
2
Transcript of Geometric Transformations Hearn & Baker Chapter 5 Some slides are taken from Robert Thomsons notes.
Geometric TransformationsHearn & Baker Chapter 5
Some slides are taken from Robert Thomsons notes.
OVERVIEW
• Two dimensional transformations• Matrix representations• Inverse transformations• Three dimensional transformations
Geometric transformation functions
• Translation• Rotation• Scaling• Reflection• Shearing
• We first discuss the 2D transformations, then we will continue with 3D.
2D Translations
TPP
d
dT
y
xP
y
xP
dyydxx
yxP
yxPP
yx
Now
,,
torscolumn vec theDefine
axis.y toparallel d axis, x toparallel d distance a ),(Point totranslate
),,( as defined Point
y
x
yx
PP’
2D Scaling from the origin.
y
x.
0
0
y
xor
Now
0
0
matrix theDefine
. ,.
axis.y thealong s and
axis, x thealong sfactor aby ),(Point to(stretch) scale a Perform
),,( as defined Point
y
x
y
x
y
x
yx
s
sPSP
s
sS
ysyxsx
yxP
yxPP
PP’
2D Rotation about the origin.
y
x
r
r
P’(x’,y’)
P(x,y)
2D Rotation about the origin.
y
x
r
r
P’(x’,y’)
P(x,y)
y
sin.
cos.
ry
rx
x
2D Rotation about the origin.
y
x
r
r
P’(x’,y’)
P(x,y)
y
sin.
cos.
ry
rx
x
cos.sin.sin.cos.)sin(.
sin.sin.cos.cos.)cos(.
rrry
rrrx
2D Rotation about the origin.
sin.
cos.
ry
rx
cos.sin.sin.cos.)sin(.
sin.sin.cos.cos.)cos(.
rrry
rrrx
Substituting for r :
Gives us :
cos.sin.
sin.cos.
yxy
yxx
2D Rotation about the origin.
cos.sin.
sin.cos.
yxy
yxx
Rewriting in matrix form gives us :
y
x
y
x.
cossin
sincos
PRPR
,
cossin
sincosmatrix theDefine
Transformations.
• Translation.– P=T + P
• Scale– P=S P
• Rotation– P=R P
• We would like all transformations to be multiplications so we can concatenate them express points in homogenous
coordinates.
Homogeneous coordinates
• Add an extra coordinate, W, to a point.– P(x,y,W).
• Two sets of homogeneous coordinates represent the same point if they are a multiple of each other.– (2,5,3) and (4,10,6) represent the same point.
• At least one component must be non-zero (0,0,0) is not defined.
• If W 0 , divide by it to get Cartesian coordinates of point (x/W,y/W,1).
• If W=0, point is said to be at infinity.
Homogeneous coordinates
• If we represent (x,y,W) in 3-space, all triples representing the same point describe a line passing through the origin.
• If we homogenize the point, we get a point of form (x,y,1)– homogenised points form a plane at W=1.
P
X
Y
W
W=1 plane
Translations in homogenised coordinates
• Transformation matrices for 2D translation are now 3x3.
1
.
100
10
01
1
y
x
d
d
y
x
y
x
11
y
x
dyy
dxx
Concatenation.
• We perform 2 translations on the same point:
),(),(),(
:expect weSo
),(),(),(
),(
),(
21212211
21212211
22
11
yyxxyxyx
yyxxyxyx
yx
yx
ddddTddTddT
ddddTPddTddTPP
ddTPP
ddTPP
Concatenation.
?
100
10
01
.
100
10
01
: is ),(),(product matrix The
2
2
1
1
2211
y
x
y
x
yxyx
d
d
d
d
ddTddT
Matrix product is variously referred to as compounding, concatenation, or composition
Concatenation.
Matrix product is variously referred to as compounding, concatenation, or composition.This single matrix is called the Coordinate Transformation Matrix or CTM.
100
10
01
100
10
01
.
100
10
01
: is ),(),(product matrix The
21
21
2
2
1
1
2211
yy
xx
y
x
y
x
yxyx
dd
dd
d
d
d
d
ddTddT
Properties of translations.
),(),(T 4.
),(),(),(),( 3.
),(),(),( 2.
)0,0( 1.
1-yxyx
yxyxyxyx
yyxxyxyx
ssTss
ssTttTttTssT
tstsTttTssT
IT
Note : 3. translation matrices are commutative.
Homogeneous form of scale.
y
xyx s
sssS
0
0),(
Recall the (x,y) form of Scale :
100
00
00
),( y
x
yx s
s
ssS
In homogeneous coordinates :
Concatenation of scales.
!multiply easy to -matrix in the elements diagonalOnly
100
0ss0
00ss
100
0s0
00s
.
100
0s0
00s
: is ),(),(product matrix The
y2y1
x2x1
y2
x2
y1
x1
2211
yxyx ssSssS
Reflection
corresponds to negative scale factors
originalsx = -1 sy = 1
sx = -1 sy = -1 sx = 1 sy = -1
Homogeneous form of rotation.
1
.
100
0cossin
0sincos
1
y
x
y
x
)()(
: i.e ,orthogonal are matricesRotation
).()(
matrices,rotation For
1
1
TRR
RR
i.e. the inverse is the transpose
Orthogonality of rotation matrices.
100
0cossin
0sincos
)( ,
100
0cossin
0sincos
)(
TRR
100
0cossin
0sincos
100
0cossin
0sincos
)(
R
Other properties of rotation.
matters.order Otherwise
same, thearerotation of centres theifonly
)()()()(
and
)()()(
)0(
RRRR
RRR
IR
2D Composite Transformations
• Combine transformations of different type– translate, rotate, translate– translate, scale, translate– translate, reflect, translate
• Use to rotate or scale an object w.r.t. a point that is not the origin
• Implement by multiplication of the corresponding homogeneous matrices
reflection in x and y axes reflection in origin
1 0
1
x x
y xb b y
1
0 1
x x y
y y
a a
Shx gives the slope of a vertical line after shear, as dx/dy
Example 1
y
yx
x
y
xyxT
4.0
14.0
01),(
)1,0(
)0,1(
)1,1(
)0,0(
S
x
Example 1
x
y
yx
x
yxT
4.0
),(
S
)1,0(
)0,1(
)1,1(
)0,0(
Example 1
y
)1,0(
)4.0,1(
)0,0(
T(S)
yx
x
yxT
4.0
),()4.1,1(
x
Example 2
0.6
0.6
1( , )
0 1
xT x y
y
x y
y
y
Sx
)1,0(
)0,1(
)1,1(
)0,0(
Example 2
0.6( , )
x yT x y
y
x
y
S
)1,0(
)0,1(
)1,1(
)0,0(
Example 2
( , ) 0.6x y
T x yy
x
y
)1,0(
)0,1()0,0(
T(S)
(0.6,1) (1.6,1)
Summary
Shear in x:
Shear in y:
y
yshx
y
xshSh xx
x 10
1
yxsh
x
y
x
shSh
yyy .1
01
Double Shear: not commutative!
ab)(10
1
1
01
1
1
b
aa
b
1
1 ab)(
1
01
10
1
b
a
b
a
Shear Matrix defined by angle, not slope
e.g. simple shear along x axis
x’ = x + y cot y’ = yz’ = z
1000
0100
0010
00cot 1
H() =
3D Transformations.
• Use homogeneous coordinates, just as in 2D case.• Transformations are now 4x4 matrices.• We will use a right-handed (world) coordinate system -
( z out of page ).
z (out of page)
y
x
Note:Convenient to think of display asBeing left-handed !!( z into the screen )
Simple extension to the 3D case:
Scale in 3D.
1000
000
000
000
),,(z
y
x
zyx s
s
s
sssS
Simple extension to the 3D case:
Rotation in 3D
• Need to specify which axis the rotation is about.• z-axis rotation is the same as the 2D case.
1000
0100
00cossin
00sincos
)(
zR
Rotation around an axis parallel to x-axis
H&B p271
Rows of upper-left 3x3 submatrix, when rotated by R lie on the x,y and z axes
1
1
0
0
1
1
0
1
0
1
1
0
0
1
1
33
32
31
23
22
21
13
12
11
r
r
r
Rr
r
r
Rr
r
r
R
Scaling an object with this transformation will also move its position relative to the origin - so move it to the origin, scale it, then move it back...