transformations
DESCRIPTION
tranformation docTRANSCRIPT
-
1Tranformations
Some slides adapted from Octavia Camps
-
2Matrices
nmnn
m
m
m
mn
aaa
aaa
aaa
aaa
A
21
33231
22221
11211
mnmnmn BAC Sum:Sum:
ijijij bac
A and B must have the same A and B must have the same dimensionsdimensions
-
3Matrices
pmmnpn BAC Product:Product:
m
kkjikij bac
1
A and B must have A and B must have compatible dimensionscompatible dimensions
nnnnnnnn ABBA
Identity Matrix:
AAIIAI
100
010001
-
4Matrices
Associative T*(U*(V*p)) = (T*U*V)*p Distributive T*(u+v) = T*v + T*v
-
5Matrices
mnT
nm AC Transpose:Transpose:
jiij ac TTT ABAB )(
TTT BABA )(
IfIf AAT A is symmetricA is symmetric
-
6MatricesDeterminant:Determinant: A must be squareA must be square
3231
222113
3331
232112
3332
232211
333231
232221
131211
detaa
aaa
aa
aaa
aa
aaa
aaa
aaa
aaa
122122112221
1211
2221
1211det aaaaaa
aa
aa
aa
-
7Matrices
IAAAA nnnnnnnn
11
Inverse:Inverse: A must be squareA must be square
1121
1222
12212211
1
2221
1211 1aa
aa
aaaaaa
aa
-
8Euclidean transformations
-
92D Translation
ttPP
PP !!
-
10
2D Translation Equation
PP
xxyy
ttxx
ttyyPP !!tt
tPP ),(' yx tytx
),(),(
yx tt
yx
tP
-
11
2D Translation using Matrices
PP
xxyy
ttxx
ttyyPP !!tt
),(),(
yx tt
yx
tP
110
01
' yx
t
t
tytx
y
x
y
xP
tt PP
-
12
Scaling
PP
PP !!
-
13
Scaling Equation
PP
xxyy
s.xs.x
PP !!s.ys.y
),('),(sysx
yx
PP
PP s'
yx
s
s
sysx
00
'P
SPSP '
-
14
RotationPP
PP !!
-
15
Rotation EquationsCounterCounter--clockwise rotation by an angle clockwise rotation by an angle
yx
yx
cossinsincos
'
'
PPxx
YY !!PP !!
XX !!yy R.PP'
-
16
Why does multiplying points by R rotate them? Think of the rows of R as a new coordinate system. Taking inner products of each points with these expresses that point in that coordinate system.
This means rows of R must be orthonormal vectors (orthogonal unit vectors).
Think of what happens to the points (1,0) and (0,1). They go to (cos theta, -sin theta), and (sin theta, cos theta). They remain orthonormal, and rotate clockwise by theta.
Any other point, (a,b) can be thought of as a(1,0) + b(0,1). R(a(1,0)+b(0,1) = Ra(1,0) + Ra(0,1) = aR(1,0) + bR(0,1). So its in the same position relative to the rotated coordinates that it was in before rotation relative to the x, y coordinates. That is, its rotated.
-
17
Degrees of Freedom
R is 2x2 R is 2x2 4 elements4 elementsBUT! There is only 1 degree of freedom: BUT! There is only 1 degree of freedom:
1)det(
RIRRRR TT
The 4 elements must satisfy the fol lowing constraints:The 4 elements must satisfy the fol lowing constraints:
yx
yx
cossinsincos
'
'
-
18
Transformations can be composed
Matrix multiplication is associative. Combine series of transformations into
one matrix. (example, whiteboard). In general, the order matters. (example,
whiteboard). 2D Rotations can be interchanged.
Why?
-
19
Rotation and Translation
100
tycos sin tx-sin cos ( )(
1yx )
100
tyabtx-ba( )(
1yx )
Rotation, Scaling and Translation
-
20
Rotation about an arbitrary point
Can translate to origin, rotate, translate back. (example, whiteboard).
This is also rotation with one translation. Intuitively, amount of rotation is same
either way. But a translation is added.
-
21
Inverse of a rotation If R is a rotation, RRT = I.
This is because the diagonals of RRT are the magnitudes of the rows, which are all 1, because the rows are unit vectors giving directions.
The off-diagonals are the inner product of orthogonal unit vectors, which are zero.
So the transpose of R is its inverse, a rotation of equal magnitude in the opposite direction.
-
22
Stretching Equation
PP
xxyy
SSxx.x.x
PP !!SSyy.y.y
yx
s
s
ysxs
y
x
y
x
00
'P
),('),(
ysxsyx
yx
PP
SPSP '
-
23
Stretching = tilting and projecting(with weak perspective)
yx
s
s
syx
s
s
ysxs
y
x
yy
x
y
x
10
00
0'P
-
24
Linear Transformation
yx
s
s
s
yx
s
s
yx
dcba
y
x
y
y
x
sincoscossin
10
0sincoscossin
sincoscossin
00
sincoscossin
'PSVD
-
25
Affine Transformation
1' y
x
tydctxba
P
-
26
Viewing Position Express world in new coordinate
system. If origins same, this is done by taking
inner product with new coordinates. Otherwise, we must translate.
-
27
Suppose, for example, we want to have the y axis show how we are facing. We want to be at (7,3), facing in direction (ct,st). The x axis must be orthogonal, (-st,ct). If we want to express (x,y) in this coordinate frame, we need to take: (ct,st)*(x-7,y-3), and (-st,ct)*(x-7,y-3). This is done by multiplying by matrix with rows (-st,ct) and (ct,st)
-
28
Simple 3D Rotation
n
n
n
zzz
yyyxxx
21
21
21...
1000cossin0sincos
Rotation about z axis.Rotates x,y coordinates. Leaves z coordinates fixed.
-
29
Full 3D Rotation
cossin0sincos0
001
cos0sin010
sin0cos
1000cossin0sincos
R
Any rotation can be expressed as combination of three rotations about three axes.
100010001
TRR Rows (and columns) of R are orthonormal vectors.
R has determinant 1 (not -1).
-
30
Intuitively, it makes sense that 3D rotations can be expressed as 3 separate rotations about fixed axes. Rotations have 3 degrees of freedom; two describe an axis of rotation, and one the amount. Rotations preserve the length of a vector, and the angle between two vectors. Therefore, (1,0,0), (0,1,0), (0,0,1) must be orthonormal after rotation. After rotation, they are the three columns of R. So these columns must be orthonormal vectors for R to be a rotation. Similarly, if they are orthonormal vectors (with determinant 1) R will have the effect of rotating (1,0,0), (0,1,0), (0,0,1). Same reasoning as 2D tells us all other points rotate too.
Note if R has determinant -1, then R is a rotation plus a reflection.
-
31
3D Rotation + Translation
Just like 2D case
-
32
Transformation of lines/normals
2D. Line is set of points (x,y) for which (x,y).(ab)T=0. Suppose we rotate points by R. We want a matrix, T, so that:
R*(x,y) .T
-
33
3D Viewing Position Rows of rotation matrix correspond to
new coordinate axis.
-
34
Rotation about a known axis
Suppose we want to rotate about u. Find R so that u will be the new z axis.
u is third row of R. Second row is anything orthogonal to u. Third row is cross-product of first two. Make sure matrix has determinant 1.