lecture 2 transformations · lecture 2 1 lecture 2 transformations. transformations. what is a...
TRANSCRIPT
![Page 1: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/1.jpg)
Computer Graphics
Lecture 2 1
Lecture 2
Transformations
![Page 2: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/2.jpg)
Transformations.
What is a transformation?
• P′=T(P) What does it do?
Transform the coordinates / normal vectors of objects
Why use them?
2
• Modelling
-Moving the objects to the desired location in the environment -Multiple instances of a prototype shape
-Kinematics of linkages/skeletons – character animation
• Viewing– Virtual camera: parallel and perspective projections
![Page 3: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/3.jpg)
Types of Transformations
– Geometric Transformations• Translation• Rotation• scaling
•• Linear Linear (preserves parallel lines) • Non-uniform scales, shears or skews
3
• Non-uniform scales, shears or skews– Projection (preserves lines)
• Perspective projection• Parallel projection
– Non-linear (lines become curves) • Twists, bends, warps, morphs,
![Page 4: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/4.jpg)
Geometric Transformation
– Once the models are prepared, we need to place them in the environment
– Objects are defined in their own local coordinate system
– We need to translate, rotate and scale them to put them into the world coordinate system
22/09/2011 Lecture 1 4
![Page 5: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/5.jpg)
2D Translations.
dyydxx
yxP
yxPP
yx +=′+=′
′′′
torscolumn vec theDefine
axis.y toparallel d axis, x toparallel d distance a ),(Point totranslate
),,( as defined Point
yx
5
TPP
d
dT
y
xP
y
xP
+=′
=
′′
=′
=
Now
,,
torscolumn vec theDefine
y
x
PP’
![Page 6: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/6.jpg)
2D Scaling from the origin.
=′=′
′′′
. ,.
axis.y thealong s and
axis, x thealong sfactor aby ),(Point to(stretch) scale a Perform
),,( as defined Point
y
x
yx ysyxsx
yxP
yxPP
6
=
′′
⋅=′
=
y
x.
0
0
y
xor
Now
0
0
matrix theDefine
y
x
y
x
s
sPSP
s
sS
PP’
![Page 7: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/7.jpg)
2D Rotation about the origin.
y
P’(x’,y’) θ
7
x
r
r
P’(x’,y’)
P(x,y)
![Page 8: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/8.jpg)
2D Rotation about the origin.
y
P’(x’,y’)
8
x
r
r
P’(x’,y’)
P(x,y)
θφ
y
φφ
sin.
cos.
ry
rx
==
x
![Page 9: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/9.jpg)
2D Rotation about the origin.
y
P’(x’,y’)
θφθφφθθφθφφθ
cos.sin.sin.cos.)sin(.
sin.sin.cos.cos.)cos(.
rrry
rrrx
+=+=′−=+=′
9
x
r
r
P’(x’,y’)
P(x,y)
θφ
yφφ
sin.
cos.
ry
rx
==
x
![Page 10: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/10.jpg)
2D Rotation about the origin.
θφθφφθθφθφφθ
cos.sin.sin.cos.)sin(.
sin.sin.cos.cos.)cos(.
rrry
rrrx
+=+=′−=+=′
Substituting for r :
10
φφ
sin.
cos.
ry
rx
==
Gives us :
θθθθ
cos.sin.
sin.cos.
yxy
yxx
+=′−=′
![Page 11: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/11.jpg)
2D Rotation about the origin.
θθθθ
cos.sin.
sin.cos.
yxy
yxx
+=′−=′
Rewritingin matrix form gives us :
11
Rewritingin matrix form gives us :
−=
′′
y
x
y
x.
cossin
sincos
θθθθ
PRPR ⋅=′
−= ,
cossin
sincosmatrix theDefine
θθθθ
![Page 12: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/12.jpg)
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.
12
−=
′′
y
x
y
x.
cossin
sincos
θθθθ
![Page 13: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/13.jpg)
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.same point if they are a multiple of each other.
– (2,5,3) and (4,10,6) represent the same point.
• 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.
13
![Page 14: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/14.jpg)
Translations in homogenised
coordinates
• Transformation matrices for 2D translation
are now 3x3.are now 3x3.
14
=
′′
1
.
100
10
01
1
y
x
d
d
y
x
y
x
11
=
+=′+=′
y
x
dyy
dxx
![Page 15: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/15.jpg)
Concatenation.
• When we perform 2 translations on the same point
),( 11 yx PddTP ⋅=′
15
),(),(),(
:expect weSo
),(),(),(
),(
21212211
21212211
22
yyxxyxyx
yyxxyxyx
yx
ddddTddTddT
PddddTPddTddTP
PddTP
++=⋅
⋅++=⋅⋅=′′
′⋅=′′
![Page 16: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/16.jpg)
Concatenation.
0101
: is ),(),(product matrix The
21
2211
⋅
xx
yxyx
dd
ddTddT
16
?
100
10.
100
10 2
2
1
1
=
y
x
y
x
dd
Matrix product is variously referred to as compounding, concatenation, or composition
![Page 17: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/17.jpg)
Concatenation.
++
=
⋅
010101
: is ),(),(product matrix The
2121
2211
xxxx
yxyx
dddd
ddTddT
17
Matrix product is variously referred to as compounding, concatenation, or composition.
+=
100
10
100
10.
100
10 2121 yyyy dddd
![Page 18: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/18.jpg)
Properties of translations.
),(),(),(),( 3.
),(),(),( 2.
)0,0( 1.
yyxxyxyx
ssTttTttTssT
tstsTttTssT
IT
⋅=⋅
++=⋅=
18
),(),(T 4.
),(),(),(),( 3.1-
yxyx
yxyxyxyx
ssTss
ssTttTttTssT
−−=
⋅=⋅
Note : 3. translation matrices are commutative.
![Page 19: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/19.jpg)
Homogeneous form of scale.
=
y
x
yx s
sssS
0
0),(
Recall the (x,y) form of Scale :
19
=100
00
00
),( y
x
yx s
s
ssS
In homogeneous coordinates :
![Page 20: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/20.jpg)
Concatenation of scales.
00ss00s00s
: is ),(),(product matrix The
x2x1x2x1
2211
⋅
⋅ yxyx ssSssS
20
!multiply easy to -matrix in the elements diagonalOnly
100
0ss0
00ss
100
0s0
00s
.
100
0s0
00s
y2y1
x2x1
y2
x2
y1
x1
⋅⋅
=
![Page 21: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/21.jpg)
Homogeneous form of rotation.
−=
′′
1
.
100
0cossin
0sincos
1
y
x
y
x
θθθθ
21
)()(
: i.e ,orthogonal are matricesRotation
).()(
matrices,rotation For
1
1
θθ
θθ
TRR
RR
=
−=
−
−
![Page 22: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/22.jpg)
Orthogonality of rotation
matrices.
−=
−
= 0cossin
0sincos
)( ,0cossin
0sincos
)( θθθθ
θθθθθ
θ TRR
22
−=
=100
0cossin)( ,
100
0cossin)( θθθθθθ TRR
−=
−−−−−
=−100
0cossin
0sincos
100
0cossin
0sincos
)( θθθθ
θθθθ
θR
![Page 23: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/23.jpg)
Other properties of rotation.
and
)()()(
)0(
φθφθ RRR
IR
+=⋅=
23
careful more be toneed ,rotations 3DFor
same theis
rotation of axis thebecauseonly is But this
)()()()(
and
θφφθ RRRR ⋅=⋅
![Page 24: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/24.jpg)
How are transforms combined?
(0,0)
(1,1) (2,2)
(0,0)
(5,3)
(3,1) Scale(2,2) Translate(3,1)
Scale then Translate
Use matrix multiplication: p' = T ( S p ) = TS p
02/10/09 Lecture 4 24
TS =2
0
0
2
0
0
1
0
0
1
3
1
2
0
0
2
3
1=
Use matrix multiplication: p' = T ( S p ) = TS p
Caution: matrix multiplication is NOT commutative!
0 0 1 0 0 1 0 0 1
![Page 25: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/25.jpg)
Non-commutative Composition
Scale then Translate: p' = T ( S p ) = TS p
(0,0)
(1,1) (2,2)
(0,0)
(5,3)
(3,1) Scale(2,2) Translate(3,1)
02/10/09 Lecture 4 25
Translate then Scale: p' = S ( T p ) = ST p
(0,0)
(1,1) (4,2)
(3,1)
(8,4)
(6,2) Translate(3,1) Scale(2,2)
![Page 26: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/26.jpg)
Non-commutative Composition
TS =2
0
0
0
2
0
0
0
1
1
0
0
0
1
0
3
1
1
Scale then Translate: p' = T ( S p ) = TS p
2
0
0
0
2
0
3
1
1
=
02/10/09 Lecture 4 26
ST =2
0
0
2
0
0
1
0
0
1
3
1
2
0
0
2
6
2=
Translate then Scale: p' = S ( T p ) = ST p
0 0 1 0 0 1 0 0 1
![Page 27: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/27.jpg)
How are transforms combined?
(0,0)
(1,1) (0,sqrt(2))
(0,0)
(3,sqrt(2))
(3,0)
Rotate 45 deg Translate(3,0)
Rotate then Translate
Translate then Rotate
02/10/09 Lecture 4 27
Caution: matrix multiplication is NOT commutative!
Translate then Rotate
(0,0)
(1,1)
(0,0) (3,0)
Rotate 45 deg Translate(3,0) (3/sqrt(2),3/sqrt(2))
![Page 28: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/28.jpg)
Non-commutative Composition
TR =0
1
0
-1
0
0
0
0
1
1
0
0
0
1
0
3
1
1
Rotate then Translate: p' = T ( R p ) = TR p
0
0
0
-1
0
0
3
1
1=
0
1
0
-1
0
0
0
0
1
0
1
0
-1
0
0
0
0
1
02/10/09 Lecture 4 28
RT =1
0
0
1
3
1
0
1
0
-1
0
0
-1
3
1=
=Translate then Rotate: p' = R ( T p ) = RT p
0 0 1
0
1
0
-1
0
0
0
0
1
0
1
0
-1
0
0
0
0
1
0
1
0
-1
0
0
0
0
1
![Page 29: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/29.jpg)
Types of transformations.
• Rotation and translation
– Angles and distances are preserved
– Unit cube is always unit cube
– Rigid-Body transformations.
• Rotation, translation and scale.
– Angles & distances not preserved.
– But parallel lines are.
29
![Page 30: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/30.jpg)
Transformations of coordinate
systems.• Have been discussing transformations as
transforming points.
• Always need to think the transformation in the • Always need to think the transformation in the world coordinate system
• Sometimes this might not be so convenient
– i.e. rotating objects at its location
30
![Page 31: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/31.jpg)
Transformations of coordinate
systems - Example • Concatenate local
transformation matricesfrom left to right
• Can obtain the local –
31
• Can obtain the local –world transformationmatrix
• p’,p’’,p’’’ are the world coordinates of p after each transformation
![Page 32: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/32.jpg)
Transformations of coordinate
systems - example
32
• is the world coordinate of point p after n transformations
![Page 33: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/33.jpg)
Quiz
• I sat in the car, and find the side mirror is 0.4m on my right and 0.3m in my front
• I started my car and drove 5m forward, turned 30 degrees to right, moved 5m forward again, and
33
degrees to right, moved 5m forward again, and turned 45 degrees to the right, and stopped
• What is the position of the side mirror now, relative to where I was sitting in the beginning?
![Page 34: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/34.jpg)
Solution
• The side mirror position is locally
(0,4,0.3)
• The matrix of first driving
forward 5m isforward 5m is
34
=100
510
001
1T
![Page 35: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/35.jpg)
Solution
• The matrix to turn to the right
30 and 45 degrees (rotating -30
and -45 degrees around the
origin) are origin) are
35
lyrespective ,
100
02
1
2
1
02
1
2
1
,
100
02
3
2
1
02
1
2
3
21
−=
−= RR
![Page 36: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/36.jpg)
Solution
The local-to-global transformation matrix at the last configuration of the car is
−
−
= 11
02
1
2
1
00131
02
1
2
3
001
The final position of the side mirror can be computed by TR1TR2 p which is around (2.89331, 9.0214)
36
−
−
=
100
02
1
2
1
100
510
100
02
3
2
1
100
51021TRTR
![Page 37: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/37.jpg)
This is convenient for character
animation / robotics
• In robotics / animation, we often want to know what is the current 3D location of the end effectors (like the
37
the end effectors (like the hand)
• Can concatenate matricesfrom the origin of the body towards the end effecter
![Page 38: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/38.jpg)
Transformations of coordinate
systems.
)()(
ji
)(
i systemin point a toj systemin point a converts that transform theas M Define
system coordinatein point a as Define
←
←
⋅= jji
i
i
PMP
iP
Lecture 4 38
1
)()(
:shown that be alsocan It
:onsubstitutiby obtain we
and
−←←
←←←
←
←
=
⋅=
⋅=
jiij
kjjiki
kkj
j
ji
MM
MMM
PMP
![Page 39: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/39.jpg)
3D Transformations.
• Use homogeneous coordinates, just as in 2D case.
• Transformations are now 4x4 matrices.
• We will use a right-handed (world) coordinate • We will use a right-handed (world) coordinate
system - ( z out of page ).
02/10/09 Lecture 4 39
![Page 40: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/40.jpg)
Translation in 3D.
Simple extension to the 3D case:
40
=
1000
100
010
001
),,(z
y
x
zyx d
d
d
dddT
![Page 41: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/41.jpg)
Scale in 3D.
Simple extension to the 3D case:
41
=
1000
000
000
000
),,(z
y
x
zyx s
s
s
sssS
![Page 42: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/42.jpg)
Rotation in 3D
• Need to specify which axis the rotation is about.
• z-axis rotation is the same as the 2D case.
42
−
=
1000
0100
00cossin
00sincos
)(θθθθ
θzR
![Page 43: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/43.jpg)
Rotating About the x-axis Rx(θ)
0001 xx
43
⋅
−=
′′
11000
0θcosθsin0
0θsinθcos0
0001
1
z
y
x
z
y
x
![Page 44: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/44.jpg)
Rotating About the y-axis
Ry(θ)
′ 0θsin0θcos xx
44
⋅
−=
′
′
11000
0θcos0θsin
0010
0θsin0θcos
1
z
y
x
z
y
x
![Page 45: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/45.jpg)
Rotation About the z-axis
Rz(θ)
− ′ 00θsinθcos xx
45
⋅
−
=
′′
11000
0100
00θcosθsin
00θsinθcos
1
z
y
x
z
y
x
![Page 46: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/46.jpg)
Rotation about an
arbitrary axis• About (ux, uy, uz), a unit
vector on an arbitrary axis
x' xuxux(1-c)+c 0uzux(1-c)-uzs uxuz(1-c)+uys
Rotate(k, θ)
x
y
z
θ
u
46
x'
y'
z'
1
=
x
y
z
1
uxux(1-c)+c
uyux(1-c)+uzs
uzux(1-c)-uys
0
0
0
0
1
uzux(1-c)-uzs
uzux(1-c)+c
uyuz(1-c)+uxs
0
uxuz(1-c)+uys
uyuz(1-c)-uxs
uzuz(1-c)+c
0
where c = cos θ & s = sin θ
![Page 47: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/47.jpg)
Rotation
• Not commutative if the axis of rotation are
not parallel
)()()()( αββα xyyx RRRR ≠
02/10/09
)()()()( αββα xyyx RRRR ≠
![Page 48: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/48.jpg)
Shearing
48
1000
0100
001
0001
a
1000
0100
0010
001 a
![Page 49: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/49.jpg)
Calculating the world coordinates of all vertices
• For each object, there is a local-to-global transformation matrix
• So we apply the transformations to all the vertices of each object
• We now know the world coordinates of all • We now know the world coordinates of all the points in the scene
49
![Page 50: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/50.jpg)
Normal Vectors
• We also need to know the direction of the normal vectors in the world coordinate system
• This is going to be used at the shading operation • We only want to rotate the normal vector• Do not want to translate it
50
![Page 51: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/51.jpg)
Normal Vectors - (2)
• We need to set elements of the translation part to zero
0111111111111 rrrtrrr x
51
⇒
1000
0
0
0
1000111111
111111
111111
111111
111111
111111
rrr
rrr
rrr
trrr
trrr
trrr
z
y
x
![Page 52: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/52.jpg)
Viewing
• Now we have the world coordinates of all the vertices
• Now we want to convert the scene so that it appears in front of the camera
52
![Page 53: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/53.jpg)
View Transformation
�We want to know the positions in the camera coordinate system
�We can compute the camera-to-world transformation matrix using the orientation and translation of the camera from the origin of the world coordinate system
Mw←c
Lecture 4 53
Mw←c
![Page 54: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/54.jpg)
View Transformation
�We want to know the positions in the camera coordinate system
vw = Mw←c vc
Point in theworld coordinate
Point in thecamera coordinate
Camera-to-world transformation
54
vc = Mw ← c vw
= Mc←w vw
-1
world coordinate
![Page 55: Lecture 2 Transformations · Lecture 2 1 Lecture 2 Transformations. Transformations. What is a transformation? ... – Virtual camera: parallel and perspective projections. Types](https://reader035.vdocuments.us/reader035/viewer/2022062603/5f04caf67e708231d40fbb88/html5/thumbnails/55.jpg)
Summary.
• Transformations: translation, rotation and scaling
• Using homogeneous transformation, 2D (3D) transformations can be represented by multiplication of a 3x3 (4x4) matrix
• Multiplication from left-to-right can be • Multiplication from left-to-right can be considered as the transformation of the coordinate system
• Need to multiply the camera matrix from the left at the end
• Reading: Foley et al. Chapter 5, Appendix 2 sections A1 to A5 for revision and further background (Chapter 5)
55