modeling transformations
DESCRIPTION
Modeling Transformations. CSE 409. Md. Tanvir Al Amin* Lecturer, Dept. of CSE, BUET [email protected]. *Special Thanks to Tanvir Parvez , Fredo Durand, James O Brien, Tomas Lozano-Perez, Jovan Popovic. Modeling Transformation - Class 1. Transformation Background. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/1.jpg)
1
Modeling Transformations
Md. Tanvir Al Amin*Lecturer, Dept. of CSE, BUET
CSE 409
*Special Thanks to Tanvir Parvez, Fredo Durand, James O Brien, Tomas Lozano-Perez, Jovan Popovic
![Page 2: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/2.jpg)
Modeling Transformation - Class 1
2
![Page 3: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/3.jpg)
Transformation Background
What is Transformation ?
3
![Page 4: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/4.jpg)
What is a Transformation
Transformation:– An operation that changes one configuration
into another
For images, shapes, etc.– A geometric transformation maps positions that
define the object to other positions– Linear transformation means the transformation
is defined by a linear function... which is what matrices are good for.
4
![Page 5: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/5.jpg)
5
What is a Transformation?
A function that maps points x to points x':Applications: animation, deformation, viewing,
projection, real-time shadows, …
![Page 6: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/6.jpg)
6
Simple Transformations
Can be combinedAre these operations invertible?Yes, except scale = 0
![Page 7: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/7.jpg)
7
Rigid-Body / Euclidean Transforms
Preserves distancesPreserves angles
TranslationRotation
Rigid / Euclidean
Identity
![Page 8: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/8.jpg)
8
Similitudes / Similarity Transforms
Preserves angles
TranslationRotation
Rigid / Euclidean
Similitudes
Isotropic ScalingIdentity
![Page 9: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/9.jpg)
9
Linear Transformations
TranslationRotation
Rigid / EuclideanLinear
Similitudes
Isotropic ScalingIdentity
Scaling
Shear
Reflection
![Page 10: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/10.jpg)
10
Linear Transformations
L(p + q) = L(p) + L(q)L(ap) = a L(p)
TranslationRotation
Rigid / EuclideanLinear
Similitudes
Isotropic Scaling
Scaling
Shear
ReflectionIdentity
Translation is not linear because ap+t ≠ a(p+t)
![Page 11: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/11.jpg)
11
Affine Transformations
preserves parallel lines
TranslationRotation
Rigid / EuclideanLinear
Similitudes
Isotropic Scaling
Scaling
Shear
ReflectionIdentity
Affine
![Page 12: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/12.jpg)
6.837 Fall 06 – Durand 12
Projective Transformations
preserves lines
TranslationRotation
Rigid / EuclideanLinear
Affine
Projective
Similitudes
Isotropic Scaling
Scaling
Shear
Reflection
Perspective
Identity
![Page 13: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/13.jpg)
13
Groups
Properties of a group (element, operation):– There exists a neutral element– There exists an inverse for each member– The elements are "closed under composition"– The composition operation is associative
Example: integers under addition0 is the neutral element-x is the inverse of xx+y is an integer(x+y)+z=x+(y+z)
![Page 14: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/14.jpg)
14
Groups and Transformations
Properties of a group:– There exists an identity mapping– There exists an inverse mapping for each function– The functions are "closed under composition"– The composition operation is associative
These properties might seem trivial at first glance, but they are actually very important, because when these conditions are shown for any class of functions and their two-argument composition operation, then they form an algebraic group. – One of the consequences is that any series of translations can
be composed to a single translation. – Another consequence is that the inverse is unique.
![Page 15: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/15.jpg)
15
How are Transforms Represented?
x' = ax + by + c
y' = dx + ey + f
x'
y'
a b
d e
c
f=
x
y+
p' = M p + t
![Page 16: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/16.jpg)
16
Translation in homogenous coordinates
x' = ax + by + c
y' = dx + ey + f
x'
y‘
1
a b
d e
0 0
c
f
1
=x
y
1
p' = M p
x'
y'
a b
d e
c
f=
x
y+
p' = M p + t
Affine formulation Homogeneous formulation
![Page 17: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/17.jpg)
17
Homogeneous Co-ordinates
Translation, scaling and rotation are expressed (non-homogeneously) as:– translation: P = P + T– Scale: P = S · P– Rotate: P = R · P
Composition is difficult to express, since translation not expressed as a matrix multiplication
Homogeneous coordinates allow all three to be expressed homogeneously, using multiplication by 3 matrices
W is 1 for affine transformations in graphics
![Page 18: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/18.jpg)
18
Homogeneous Coordinates
Add an extra dimension• in 2D, we use 3 x 3 matrices
• In 3D, we use 4 x 4 matrices
Each point has an extra value, wx'
y'
z'
w'
=
x
y
z
w
a
e
i
m
b
f
j
n
c
g
k
o
d
h
l
p
p' = M p
![Page 19: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/19.jpg)
19
Homogeneous Coordinates
Most of the time w = 1, and we can ignore it
If we multiply a homogeneous coordinate by an affine matrix, w is unchanged
x'
y'
z'
1
=
x
y
z
1
a
e
i
0
b
f
j
0
c
g
k
0
d
h
l
1
![Page 20: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/20.jpg)
20
Homogeneous Co-ordinates
P2d is a projection of Ph onto the w = 1 plane
So an infinite number of points correspond to : they constitute the whole line (tx, ty, tw)
x
y
w Ph(x,y,w)
P2d(x,y,1)
w=1
![Page 21: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/21.jpg)
Homogeneous Visualization
![Page 22: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/22.jpg)
Mechanics of Rigid Transformations
Translate
Rotate
Scale
22
![Page 23: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/23.jpg)
23
Translation – 2D
(4,5) (7,5)
Y
XBefore Translation
1
*
100
10
01
1
y
x
d
d
y
x
TPPd
dT
y
xP
y
xP
y
x
y
x
Form sHomogeniou
x’ = x + dx y’ = y + dy
(7,1) (10,1)
X
Y
Translation by (3,-4)
![Page 24: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/24.jpg)
24
Translation – 3D
PPdddT
dz
dy
dx
z
y
x
d
d
d
zyx
z
y
x
z
y
x
*),,(
11
*
1000
100
010
001
z
y
x
dzz
dyy
dxx
![Page 25: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/25.jpg)
25
Scaling – 2D
(4,5) (7,5)
Y
X(2,5/4) (7/2,5/4)
X
Y
Before Scaling Scaling by (1/2, 1/4)
y
x
y
x
y
x
sy
sx
y
x
s
s
PPS
ysy
xsx
*
**
0
0
*
*
*
Types of Scaling:
Differential ( sx != sy )Uniform ( sx = sy )
1
*
100
00
00
1
Form sHomogeniou
y
x
s
s
y
x
y
x
![Page 26: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/26.jpg)
26
Scaling – 3D
1
*
*
*
1
*
1000
000
000
000
*),,(
z
y
x
z
y
x
zyx
sz
sy
sx
z
y
x
s
s
s
PPsssS
Original
scale all axes
scale Y axiszsz
ysy
xsx
z
y
x
*
*
*
![Page 27: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/27.jpg)
Rotation – 2D
sin
cos
r
rv
rota
ted
cossinsincos
sinsincoscos expand
rry
rrx
cossin
sincos
sin
cosbut
yxy
yxx
ry
rx
original
sin
cos
r
rv
![Page 28: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/28.jpg)
28
Rotation – 2D
(5,2) (9,2)
Y
X
(2.1,4.9)
(4.9,7.8)
X
YBefore Rotation Rotation of 45 deg. w.r.t. origin
1
*
100
0cossin
0sincos
1
Form sHomogeniou
y
x
y
x
cos*sin*
sin*cos**
cossin
sincos
*
yx
yx
y
x
PPR
yyx
xyx
cos*sin*
sin*cos*
![Page 29: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/29.jpg)
Modeling Transformation - Class 2
29
![Page 30: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/30.jpg)
30
Rotation – 3D
1
cos*sin*
sin*cos*
1
*
1000
0100
00cossin
00sincos
*,
z
yx
yx
z
y
x
PPR k
For 3D-Rotation 2 parameters are needed
Angle of rotation
Axis of rotation
Rotation about z-axis:
![Page 31: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/31.jpg)
31
Rotation about Y-axis & X-axis
1
cos*sin*
sin*cos*
1
*
1000
0cos0sin
0010
0sin0cos
*,
zx
y
zx
z
y
x
PPR j
1
cos*sin*
sin*cos*
1
*
1000
0cossin0
0sincos0
0001
*,
zy
zy
x
z
y
x
PPR iAbout x-axis
About y-axis
![Page 32: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/32.jpg)
32
Rotation about Z axis
About z axis
x'
y'
z'
1
=
x
y
z
1
cos θ
sin θ
0
0
-sin θ
cos θ
0
0
0
0
1
0
0
0
0
1
ZRotate(θ)
x
y
z
p
p'
θ
![Page 33: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/33.jpg)
Rotation
How to rotate around (kx, ky, kz), a unit vector on an arbitrary axis …Example : Rotate 30 degree around vector
2i+1j+3k For now, solution is Rodrigues Formula– Can it be found from some rotation around x
axis, then some rotation around y axis, then z axis ?
– We will munch it later ….
33
![Page 34: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/34.jpg)
34
Rotation
About (kx, ky, kz), a unit vector on an arbitrary axis(Rodrigues Formula)
x'
y'
z'
1
=
x
y
z
1
kxkx(1-c)+c
kykx(1-c)+kzs
kzkx(1-c)-kys
0
0
0
0
1
kykx(1-c)-kzs
kyky(1-c)+c
kzky(1-c)+kxs
0
kxkz(1-c)+kys
kykz(1-c)-kxs
kzkz(1-c)+c
0
Rotate(k, θ)
x
y
z
θ
k
We will return to this case of arbitrary rotation later …
where c = cos θ & s = sin θ
![Page 35: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/35.jpg)
Non Rigid Transforms
35
![Page 36: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/36.jpg)
Non Rigid Transforms
We just studied Translation, Scale, Rotate All these are Rigid Transformations Is Shear rigid ?
– No– Shear is Linear Transform
However, Translate, Scale, Rotate, Shear, Reflect all are member of general class “Affine Transformation”
36
![Page 37: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/37.jpg)
37
Mirror Reflection
100
010
001
axis-Xabout Reflection
xM
yyxx
100
010
001
axis-Yabout Reflection
yM
yyxx
(1,1)
(1,-1)
Y
X
(-1,1) (1,1)
X
Y
![Page 38: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/38.jpg)
38
Shearing Transformation
100
01
01
100
01
001
100
010
01
b
a
SHbSH
a
SH xyyx
unit cubeSheared in X
directionSheared in Y
directionSheared in both X
and Y direction
![Page 39: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/39.jpg)
39
Shear along Z-axis
1
*
*
1
*
1000
0100
010
001
*),(
z
shzy
shzx
z
y
x
sh
sh
PPshshSH
y
x
y
x
yxxy
y
x
z
![Page 40: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/40.jpg)
Inverse Transforms
40
![Page 41: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/41.jpg)
41
Inverse Transformations
y-y
x-x
),(-(sx,sy)
T(-θ
-(θ
(-dx,-dy)-
(dx,dy)
MM
MM
SS
RRR
TT
sysx
1
1
1
)()1)
1
:RefMirror
: Sclaing
: Rotation
:nTranslaito
11
![Page 42: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/42.jpg)
Composing Transformations
42
![Page 43: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/43.jpg)
43
How are transforms combined?
(0,0)
(1,1)(2,2)
(0,0)
(5,3)
(3,1)Scale(2,2) Translate(3,1)
TS =2
0
0
2
0
0
1
0
0
1
3
1
2
0
0
2
3
1=
Scale then Translate
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 44: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/44.jpg)
44
Non-commutative Composition
Scale then Translate: p' = T ( S p ) = TS p
Translate then Scale: p' = S ( T p ) = ST p
(0,0)
(1,1)(4,2)
(3,1)
(8,4)
(6,2)
(0,0)
(1,1)(2,2)
(0,0)
(5,3)
(3,1)Scale(2,2) Translate(3,1)
Translate(3,1) Scale(2,2)
![Page 45: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/45.jpg)
45
TS =
2
0
0
0
2
0
0
0
1
1
0
0
0
1
0
3
1
1
ST =
2
0
0
2
0
0
1
0
0
1
3
1
Non-commutative Composition
Scale then Translate: p' = T ( S p ) = TS p2
0
0
0
2
0
3
1
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 46: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/46.jpg)
46
Combining Translations, Rotations
Order matters!! TR is not the same as RT (demo)General form for rigid body transformsWe show rotation first, then translation
(commonly used to position objects) on next slide. Slide after that works it out the other way
![Page 47: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/47.jpg)
47
Rotate then Translate
' ( )P TR P MP RP T
11 12 13 11 12 13
21 22 23 21 22 23
31 32 33 31 32 33
1 0 0 0
0 1 0 0
0 0 1 0 0 1
0 0 0 1 0 0 0 1 0 0 0 1
x x
y y
z z
T R R R R R R T
T R R R R R R T R TM
T R R R R R R T
![Page 48: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/48.jpg)
48
Translate then Rotate
' ( ) ( )P RT P MP R P T RP RT
11 12 13
3 3 3 3 3 121 22 23
1 331 32 33
0 1 0 0
0 0 1 0
0 10 0 0 1
0 0 0 1 0 0 0 1
x
y
z
R R R T
R R TR R R TM
R R R T
![Page 49: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/49.jpg)
49
Classification of Transformations Again
1. Rigid-body Transformation Preserves parallelism of lines Preserves angle and length e.g. any sequence of R() and T(dx,dy)
2. Affine Transformation Preserves parallelism of lines Doesn’t preserve angle and length e.g. any sequence of R(), S(sx,sy) and T(dx,dy)
unit cube 45 deg rotaton Scale in X not in Y
![Page 50: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/50.jpg)
Example Affine Transforms
50
![Page 51: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/51.jpg)
51
Properties of rigid-body transformation
1002221
1211
y
x
trr
trr
The following Matrix is Orthogonal if the upper left 2X2 matrix has the following properties
1.A) Each row are unit vector. sqrt(r11* r11 + r12* r12) = 1
B) Each column are unit vector. sqrt(c11* c11 + c12* c12) = 1
2.A) Rows will be perpendicular to each other (r11 , r12 ) . ( r21 , r22) = 0
B) Columns will be perpendicular to each other (c11 , c12 ) . (c21 ,c22) = 0
e.g. Rotation matrix is orthogonal
100
0cossin
0sincos
• Orthogonal Transformation Rigid-Body Transformation
• For any orthogonal matrix B B-1 = BT
![Page 52: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/52.jpg)
52
Associativity of Matrix Multiplication
Create new affine transformations by multiplying sequences of the above basic transformations.
q = CBAp
q = ( (CB) A) p = (C (B A))p = C (B (Ap) ) etc.
matrix multiplication is associative.
But to transform many points, best to do
M = CBA
then do q = Mp for any point p to be rendered.
To transform just a point, better to do q = C(B(Ap))
For geometric pipeline transformation, define M and set it up with the model-view matrix and apply it to any vertex subsequently defined to its setting.
![Page 53: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/53.jpg)
Example Composite Transforms
53
2D Case
![Page 54: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/54.jpg)
54
Rotation of about P(h,k): R,P
R,P=
Q(x,y)
P(h,k)
Step 1: Translate P(h,k) to origin
T(-h ,-k)
Q1(x’,y’
)
P1 (0,0)
Step 2: Rotate w.r.t to origin
R*
Q2(x’,y’
)
P2 (0,0)
Step 3: Translate (0,0) to P(h,k0)
T(h ,k) *P3(h,k)
Q3(x’+h, y’
+k)
![Page 55: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/55.jpg)
55
Reflection about line L, ML
Step 1: Translate (0,b) to origin
T(0 ,-b)ML =
Step 2: Rotate - degrees
Step 3: Mirror reflect about X-axis
R(-) *T(0 ,b) *
Step 4: Rotate degrees
Step 5: Translate origin to (0,b)
M x*R() *
(0,b)
Y
X
t
O
Y
XO
Y
XO
Y
XO
Y
XO
(0,b)
Y
X
t
O
![Page 56: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/56.jpg)
Scale about Arbitrary Axis
56
![Page 57: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/57.jpg)
Scale about arbitrary axis
57
![Page 58: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/58.jpg)
Scale about arbitrary axis
58
![Page 59: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/59.jpg)
Scale about arbitrary axis
59
![Page 60: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/60.jpg)
Scale about arbitrary axis
60
![Page 61: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/61.jpg)
Shear
Shears are not really primitive transformsRelated to non-axis-aligned scales Express shear in terms Euclidean
transformation and non uniform scale– Its your homework – Hints on next slide– ??
61
![Page 62: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/62.jpg)
Singular Value Decomposition
62
![Page 63: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/63.jpg)
Decomposing Matrices
63
![Page 64: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/64.jpg)
64
Problems to be solved:
Schaum’s outline series:
Problems: 4.1 4.2
4.3, 4.4, 4.5 => R,P 4.6, 4.7, 4.8 => Ssx,sy,,P
4.9, 4.10, 4.11, 4.21 => ML
4.12 => Shearing Pg-281(1.24), Pg-320(5.19)
=> Circular view-port
![Page 65: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/65.jpg)
Modeling Transformation - Class 3, 4
65
![Page 66: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/66.jpg)
Exploring rotations in 3D
66
![Page 67: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/67.jpg)
Recap : Rotation
67
![Page 68: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/68.jpg)
Recap : Rotations
68
![Page 69: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/69.jpg)
Recap : Axis Aligned Rotations
69
![Page 70: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/70.jpg)
Recap : Rotation around Arbitrary Axisa=(ax,ay,az) is a normalized vector
A point x is to be rotated by angle theta around this vectorFind the Rotation Matrix
70
![Page 71: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/71.jpg)
Arsenal
That old rotation problem, for what we will check at least three solutions– Euler Theorem (Old school thing)
– Rodrigues Formula (The beautiful Construction)
– Quaternion (Latest hero in the town)
71
![Page 72: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/72.jpg)
Euler Theorem
That old school thing ….
72
![Page 73: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/73.jpg)
Euler Angles
Before considering our composite rotation around a rotation axis which ultimately will be called Euler Axis, we examine another way of rotating a body from one orientation to another orientation ….
These are the Euler Angles
73
Special note : Don’t confuse Euler theorem and Euler Angles. Euler angles are not concerned with our axis of composite rotation. Rather they specify a way to orient a co-ordinate system with another by means of defined rotationsEuler theorem is concerned with our rotation axis, which we are going to study once we are done with Euler angles.
![Page 74: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/74.jpg)
Euler Angles
Euler angles a means of representing the
spatial orientation of any frame of the space as a
composition of rotations from a reference frame.
The fixed system is denoted in lower case (x,y,z)
and the rotated system in upper case letters
(X,Y,Z).
Line of nodes (N) The intersection of the xy
and the XY coordinate planes.
• α is the angle between the x-axis and the line of nodes.
• β is the angle between the z-axis and the Z-axis. • γ is the angle between the line of nodes and the X-axis.
![Page 75: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/75.jpg)
Angle signs and ranges
α and γ range are defined modulo 2π radians. A valid range could be A valid range could be (-π, π]
β range covers π radians (but can't be said to be modulo π). For example could be [0, π] or [-π/2, π/2]
The angles α, β and γ are uniquely determined except for the singular case that – xy and the XY planes are identical,
– the z axis and the Z axis having the same or opposite directions. • if the z-axis and the Z-axis are the same, β = 0 and only (α+γ) is uniquely defined (not
the individual values),
• if the z-axis and the Z-axis are opposite, β = π and only (α-γ) is uniquely defined (not the individual values). These ambiguities are known as gimbal lock in applications.
75
![Page 76: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/76.jpg)
Euler Rotations
Change one of the Euler angles while leaving the other two constant.
Neither expressed in terms of external or internal frame, but in mixture.
• first angle moves the line of nodes around the external axis z • second rotates around the line of nodes • third one is an intrinsic rotation around an axis fixed in the body
The three rotations are called Precession, Nutation, and intRinsic rotation
Euler rotations are commutative.Used in aerodynamics. We are not going to use them
76
![Page 77: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/77.jpg)
Intrinsic or Extrinsic Rotations
Intrinsic rotation (in terms of moving body or local coordinate) or Extrinsic rotation (global coordinate) is
possible also possible with Euler angles.
77
![Page 78: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/78.jpg)
78
Intrinsic and Extrinsic Rotations
Intrinsic Rotation
• Rotate the XYZ system about the z-axis by α.
The x-axis now lies on the line of nodes.• Rotate the XYZ system again about the new
rotated x-axis by β. • Rotate the XYZ system a third time about the
new z-axis by γ.
Extrinsic Rotation
• Rotate the XYZ-system about the z-axis by γ.
• Rotate the XYZ-system again about the x-axis
by β.• Rotate the XYZ-system a third time about the
z-axis by α.
Be careful, in this notation, rotations are around z-x-z. Here y is not involved. But there are other conventions also.
![Page 79: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/79.jpg)
Order of rotations
3D rotations do not commuteEuler angles are not unique !!For a specific composite rotation, there are 12
possible orderings of three individual axis-aligned rotations, and each produce different Euler angles β1, β2, β3
One of them are called "proper" Euler angles and the other Tait–Bryan angles
79
![Page 80: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/80.jpg)
Matrix of Euler Angles
– In z-x-z convention :
– Writing the matrices
– Denoting cos by c and sin by s
- Homework : Get Euler angles from the rotation matrix
80
)().().( zxz RRRR
![Page 81: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/81.jpg)
Why Euler angles ?
When we want to go between one orientation to another, we may use the Euler anglesBut use of euler angles impose problems as
well like :
81
![Page 82: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/82.jpg)
Gimbal Lock
Consider a case of a level sensing platform on an aircraft flying due North with its three gimbal axes mutually perpendicular (i.e., roll, pitch and yaw angles each zero). If the aircraft pitches up 90 degrees, the aircraft and platform's Yaw axis gimbal becomes parallel to the Roll axis gimbal, and changes about yaw can no longer be compensated for (see illustration, red ring is pivoted to green ring and green ring is pivoted to blue ring).
The word lock is misleading: no gimbal is restrained, all three gimbals can still rotate freely about their respective axis of suspension. Nevertheless, because of the parallel orientation of both the yaw and roll gimbal axes, there is no axis available to accommodate yaw rotation.
More later
82
![Page 83: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/83.jpg)
Euler Theorem
We are now back to our previous problem, finding the rotation matrix of an arbitrary rotation around an axis.
The result is due to Euler
83
Special note : Don’t confuse Euler theorem and Euler Angles. Euler theorem is concerned with our rotation axis, we are going to study it now.Euler angles are not concerned with our axis of composite rotation. Rather they specify a way to orient a co-ordinate system with another by means of defined rotations.
![Page 84: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/84.jpg)
Euler’s Theorem
Euler’s Theorem states that– Any rotation (or sequence of rotations) about a
point is equivalent to a single rotation about some axis through that
84
Ref : Hill’s Book, page 239
(Original Statement) Quomodocunque sphaera circa centrum suum conuertatur, semper assignari potest diameter, cuius directio in situ translato conueniat cum situ initiali.
Translation: When a sphere is moved around its centre it is always possible to find a diameter whose direction in the displaced position is the same as in the initial position.
Ref : Wikipedia
This axis is called Euler
Axis
![Page 85: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/85.jpg)
Euler’s Theorem
Implication of Euler’s Theorem – The θ angle rotation around vector a can be built
from composing axis-aligned rotations– We are now going to find that …
85
![Page 86: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/86.jpg)
Finding the Rotation Matrix
Our previous method Step 1,2 Perform two rotations so that a becomes aligned
with the z-axis (two rotations are necessary) Step 3 Do the required θ rotation around z-axis Step 4,5 Undo the alignment rotations to restore a to its
original direction
86
Alignment
Rotation
Trace Back
Trivial but you should be careful when doing in hands
![Page 87: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/87.jpg)
Step 1,2
We now study a composite transformationAV,N = aligning a vector V with a vector N
To find the rotation matrix, we need to find Av,k
87
![Page 88: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/88.jpg)
88
AV : aligning vector V with k
Av = R,i
V = aI + bJ + cK
x
y
z
b
a
c
k
22λ
λcos
λsin
by axis-about x Rotate :1 Step
cbc
b
b
|V|
x
y
z
b
a
k
( 0, b,c )b
|V|
x
y
z
a
k
|V|
( a, 0, )
( 0, 0, )
( 0, b,c )
![Page 89: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/89.jpg)
89
AV : aligning vector V with k
Av = R,i R-,j *
22λ
λcos
λsin
by axis-about x Rotate :1 Step
cbc
b
222
|V|
|V|
λ)cos(
|V|)sin(
-by axis-yabout V Rotate :2 Step
cba
a
P( a, b, c)
b
x
y
z
b
a
c
k
|V|
( a, 0, )( 0, b,c )b
x
y
z
b
a
c
|V|
( 0, 0, |V|)
( 0, b,c )
a
![Page 90: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/90.jpg)
90
AV : aligning vector V with k
AV-1 = AV
T
AV,N = AN-1 * AV
1000
0
00
0
λλ
λ-
λ-λ
Vc
Vb
Va
bc
Vac
Vab
V
VA
![Page 91: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/91.jpg)
Finding the rotation matrix
Now we have done step 1,2 : AV
For step 3, we have to rotate theta angle around z axisThen take the inverse of step 1,2,
AV-1 = AV
T
There are actually 5 rotations here. None of which are Euler angles α or β or γ
91
vzTv ARAR )(
![Page 92: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/92.jpg)
Axis Angle Notation
92
sin)cos1(
100
010
001
cos),(2
2
2
zzyzx
zyyyx
zxyxx
aaaaa
aaaaa
aaaaa
aR
0
0
0
xy
xz
yz
aa
aa
aa
Rod
rigu
es F
orm
ula
![Page 93: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/93.jpg)
The Geometry of a Rotation
93
![Page 94: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/94.jpg)
The Geometry of a Rotation
94
![Page 95: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/95.jpg)
The Geometry of Rotation
95
![Page 96: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/96.jpg)
The Geometry of Rotation
So we find, the rotation vector is :
This is a vector equation, which is goodBut, we need a matrix form also, to work
easily.
96
Rodrigues Formula
Vecto
r For
m
Matrix Form
sin)cos1(
100
010
001
cos),(2
2
2
zzyzx
zyyyx
zxyxx
aaaaa
aaaaa
aaaaa
kR
0
0
0
xy
xz
yz
aa
aa
aa
![Page 97: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/97.jpg)
Rodrigues Formula
Vector and Matrix forms
How we find these equivalent matrix and vector forms ?Check next slide
97
sin)cos1(
100
010
001
cos),(
),()(
2
2
2
zzyzx
zyyyx
zxyxx
T
aaaaa
aaaaa
aaaaa
kR
XkRxR
zyxX
0
0
0
xy
xz
yz
aa
aa
aa
![Page 98: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/98.jpg)
Vector and Matrix algebra
98
![Page 99: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/99.jpg)
Cross product in Matrix Form
99
![Page 100: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/100.jpg)
Finding rotations from a rotation matrixGiven, R is a pure rotation matrixFind axis of rotation K(kx,ky,kz)
and angle theta from RRecall rodrigues formula, it gives R Check that :Trace(R ) = Sum of diagonal elements of the 3x3
rotation matrix
100
2
1)(cos
RTrace
R
![Page 101: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/101.jpg)
Finding rotations from a rotation matrixCheck that :
101
T
xy
xz
yz
RR
kk
kk
kk
)sin(2
1
0
0
0
)()sin(2
1
)()sin(2
1
)sin(2
1
2,11,2
1,33,1
3,22,3
RRk
RRk
RRk
z
y
x
R
![Page 102: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/102.jpg)
Modeling Transformation - Class 5
102
![Page 103: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/103.jpg)
Quaternion
Have you ever thought about the operations of vector algebra ? We can add vectors, subtract vectors … But multiplication ?
– We can multiply vectors, But, two ways !!– Dot product outputs scalar– Cross product outputs vector
Hey, what about division – Man….r u insane ? vector division !!
103
![Page 104: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/104.jpg)
Quaternion
Vector algebra contains subtraction as the inverse operation for addition, Null vector being the identity element. But there is no inverse vector for
multiplication operation !! That’s why we can’t divide vectors.Why no inverse ?
– A . B is scalar, inverse is out of question– A × B is vector, can we have an inverse ?
104
![Page 105: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/105.jpg)
In search of an vector inverse…
So, we want an inverse A-1 for a vector A, so that A × A-1 = Identity Or may be, we want that
– If B × A = C, then• Given C and B, find A.
• A= B-1 × C
– Is it actually possible ??
105
NONO
![Page 106: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/106.jpg)
Why ?
If A × B = C then– Given C and A, find B– If A, B, C are scalars, 5 × 3 = 15. Hence
15 / 5 = 3, uniquely defined.– But if A, B, C are vectors. B is not uniquely
defined now !!• We just know, B lies on the plane normal to C.
• B can be any vector lying on the plane normal to C, as long as
106
||
||sin||
A
CB
ϕ
![Page 107: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/107.jpg)
Why we are craving for inverse
So, what is the reason behind our wild goose search for an inverse of cross ?Because, inverse of cross product could
capture rotation around an axisThink other wayIf C and B is given,
– A is ϕ rotation away– On the plane
normal to C107
Axis of rotation
![Page 108: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/108.jpg)
Unique
How to uniquely determine B ??– The problem is not complete actually.– Only, C and A alone are not sufficient for
rotation– We need either |B| or ϕ (or sinϕ or cosϕ) to get
A from B and C– Which means, Vector B and C alone aren’t
sufficient, a scalar is needed also.– Here comes quaternion : scalar + 3D vector
108
ϕ
![Page 109: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/109.jpg)
Is it really new ?
No, actuallyWe already know something … Think about complex numbers A point (x,y) on a euclidean space can be
thought as a vector, where inverse is not possible.But if we think it as a complex number,
then inverse is possible !!!
109
![Page 110: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/110.jpg)
Complex Numbers
So, a 2D vector, ai+bj is not invertibleBut a complex number a+ib has inverse…
– Why ???
– Because there is a defined Identity element
– More importantly, there is a necessary relationship for a multiplicative space
i2 = -1And this lets us to have the idea of
conjugation110
![Page 111: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/111.jpg)
Complex Number
Actually, a complex number is not really a 2D vector.Complex Number = Scalar + 1D VectorI said Quaternion = Scalar + 3D VectorSo, what necessary properties do we need
now ?– We need something to operate with
multiplication, something like i2 = -1
111
![Page 112: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/112.jpg)
Great minds in History
Hamilton knew that the complex numbers could be viewed as points in a plane, and he was looking for a way to do the same for points in space. Points in space can be represented by their coordinates, which are triples of numbers, and for many years Hamilton had known how to add and multiply triples of numbers. But he had been stuck on the problem of division: He did not know how to take the quotient of two points in space
The breakthrough finally came on Monday 16 October 1843 in Dublin, when Hamilton was on his way to the Royal Irish Academy where he was going to preside at a council meeting. While walking along the towpath of the Royal Canal with his wife, the concept behind quaternions was taking shape in his mind. Hamilton could not resist the impulse to carve the formulae for the quaternions into the stone of Brougham Bridge as he passed by it.
i2 = j2 = k2 = ijk = − 1
112
![Page 113: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/113.jpg)
Quaternion Arsenal
– A quaternion H = [v,w]• v is vector, w is scalar
• v is 3D vector, hence
• H = [(x,y,z),w]
• Real numbers [0,s]
• Pure Vectors [v,0]
113
![Page 114: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/114.jpg)
Quaternion Arsenal
114
![Page 115: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/115.jpg)
Quaternion Arsenal
115
![Page 116: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/116.jpg)
Quaternion Arsenal
116
![Page 117: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/117.jpg)
Quaternions as Rotation
A unit quaternion aids for vector rotationIf q is a unit quaternion, p is a point stored in homogenous
coordinate [x,y,z,w] as a quaternionqpq-1 rotates p around
117
![Page 118: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/118.jpg)
Rotating a vector
118
![Page 119: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/119.jpg)
Representing objects in 3D
119
![Page 120: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/120.jpg)
120
Orientation
Thumb points to +ve Z-axisFingers show +ve rotation from X to Y
axis
Y
X
Z (out of page)
Y
X
Z (larger z areaway from viewer)
Right-handed orentation Left-handed orentation
![Page 121: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/121.jpg)
121
Vectors in 3D
Have length and direction
V = [xv , yv , zv]Length is given by the Euclidean Norm
||V|| = ( xv2 + yv
2 + zv2 )
Dot Product
V • U = [xv, yv, zv]•[xu, yu, zu]
= xv*xu + yv*yu + zv*zu = ||V|| || U|| cos ß
Cross Product V U
= [yv*zu - zv yu , -xv*zu + zv*xu , xv*yu – yv*xu ]= ||V|| || U|| sin ßV U = - ( U x V)
(xv,yv,zv)V=aI+bJ+cK
x
y
z
![Page 122: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/122.jpg)
122
3D Equation of Curve & Line
Parametric equations of Curve & LineCurve
Line
bta
thz
tgy
tfx
C
:
VtPPPtPL
t
tzzzz
tyyyy
txxxx
L
PPPPV
0010
010
010
010
0110
)(
10:
P0(x0,y0,z0)
P1(x1,y1,z1)
t > 1
Vt < 0
t =1
t = 00 < t < 1
x
y
z
C
![Page 123: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/123.jpg)
123
3D Equation of Surface & Plane
Parametric equations of Surface & PlaneSurface
Plane : with Normal, N
dtc
bsa
tshz
tsgy
tsfx
S
,
,
,
:
P0
N
kCjBiAN
DCzByAx
ˆˆˆ
0
![Page 124: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/124.jpg)
124
3D Plane
Ways of defining a plane
1. 3 points P0, P1, P2 on the plane
2. Plane Normal N & P0 on plane
3. Plane Normal N & a vector V on the plane
Plane Passing through P0, P1, P2
P0
P1
P2
N
V
)(
0
0ˆ)(ˆ)(ˆ)()ˆˆˆ(
0
ˆˆˆ
000
000
0
2010
CzByAxD
DCzByAx
kzzjyyixxkCjBiA
PPN
kCjBiAPPPPN
where
plane the on is z) y,P(x, if
![Page 125: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/125.jpg)
125
Revisit : Affine Transformation
Transformation – is a function that takes a point (or vector) and maps that point (or vector) into another point (or vector).
A coordinate transformation of the form:
x’ = axx x + axy y + axz z + bx ,
y’ = ayx x + ayy y + ayz z + by ,
z’ = azx x + azy y + azz z + bz ,
is called a 3D affine transformation.
11000
'
'
'
z
y
x
baaa
baaa
baaa
w
z
y
x
zzzzyzx
yyzyyyx
xxzxyxx
The 4th row for affine transformation is always [0 0 0 1]. Properties of affine transformation:
– translation, scaling, shearing, rotation (or any combination of them) are examples affine transformations.
– Lines and planes are preserved.– parallelism of lines and planes are also preserved, but not angles and
length.
![Page 126: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/126.jpg)
Composite 3D Transformations
126
![Page 127: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/127.jpg)
127
Object Transformation
Line: Can be transformed by transforming the end pointsPlane:(described by 3-points) Can be
transformed by transforming the 3-pointsPlane:(described by a point and Normal)
Point is transformed as usual. Special treatment is needed for transforming Normal
![Page 128: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/128.jpg)
128
Composite Transformations – 3D
Some of the composite transformations to be studied are:AV,N = aligning a vector V with a vector N
– We already studied it
R,L = rotation about an axis L( V, P )
MN,P = Mirror Reflection w.r.t a plane
Aligning a plane P with a plane Q
![Page 129: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/129.jpg)
129
R,L : rotation about an axis L
Let the axis L be represented by vector V and passing through point P
1.Translate P to the origin
2. Align V with vector k
3. Rotate about k
4. Reverse step 2
5. Reverse step 1
R,L = T-PAV *R,k *AV-1 *T-P
-1 *
V
P
Q
Q'
L
z
x
y
k
![Page 130: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/130.jpg)
130
MN,P : Mirror reflection
Let the plane be represented by plane normal N and a point P in that plane
x
y
z N
P
![Page 131: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/131.jpg)
131
MN,P : Mirror reflection
Let the plane be represented by plane normal N and a point P in that plane
1.Translate P to the origin
MN,P = T-P
x
y
z
N
P
![Page 132: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/132.jpg)
132
MN,P : Mirror reflection
Let the plane be represented by plane normal N and a point P in that plane
1.Translate P to the origin
2. Align N with vector k
MN,P = T-PAN *
N
P
x
y
z
![Page 133: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/133.jpg)
133
MN,P : Mirror reflection
Let the plane be represented by plane normal N and a point P in that plane
1.Translate P to the origin
2. Align N with vector k
3. Reflect w.r.t xy-plane
MN,P = T-PAN *S1,1,-1 *
N
P
x
y
z
![Page 134: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/134.jpg)
134
x
y
z
MN,P : Mirror reflection
Let the plane be represented by plane normal N and a point P in that plane
1.Translate P to the origin
2. Align N with vector k
3. Reflect w.r.t xy-plane
4. Reverse step 2
MN,P = T-PAN *S1,1,-1 *AN-1 *
![Page 135: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/135.jpg)
135
MN,P : Mirror reflection
Let the plane be represented by plane normal N and a point P in that plane
1.Translate P to the origin
2. Align N with vector k
3. Reflect w.r.t xy-plane
4. Reverse step 2
5. Reverse step 1
MN,P = T-PAN *S1,1,-1 *AN-1 *T-P
-1 *
x
y
z N
P
![Page 136: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/136.jpg)
136
Further Composition
The Composite Transform must have
– Translation of P1 to Origin T
zx
y3P
1P2PT
– Some Combination of Rotations R
Rx
y
z 2P
3P 1P
z
x
y3P
1P2P
Fig. 1 Fig. 2
Translate points in fig. 1 into points in fig 2 such that:– P3 is moved to yz plane
– P2 is on z-axis
– P1 is at Origin
![Page 137: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/137.jpg)
137
Finding R
xx
zyx
zyx
zzz
yyy
xxx
Rx.x R
RRR
RRR
zRyRxR
zRyRxR
zRyRxR
rrr
rrr
rrr
R
R
vextor ofcomponent :Note
other each to
lar perpendicu are ii)
vectorsunit are i)
Transform body-Rigid isR
be Let
,,
,,
...
...
...
333231
232221
131211
![Page 138: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/138.jpg)
138
Finding Rz
z
z
z
z
zyx
zyx
zyx
TT
R
zR
yR
xR
zRzRzR
yRyRyR
xRxRxR
RRkR
21
21
21
21
21
21
PP
PP
PP
PP
PP
PP
.
.
.
1
0
0
...
...
...
ˆ 1
R
z
x
y
3P
1P2P
x
y
z 2P
3P 1P
Rz
k
kR
R
ˆ
21
21
21
PP
PP
axis-z along PP aligns
![Page 139: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/139.jpg)
139
R
x
y
z 2P
3P 1P
z
x
y
3P
1P 2P
Finding Rx
x
x
x
x
zyx
zyx
zyx
R
zR
yR
xR
zRzRzR
yRyRyR
xRxRxR
iR
2131
2131
2131
2131
2131
2131
PPPP
PPPP
PPPP
PPPP
PPPP
PPPP
.
.
.
0
0
1
...
...
...
ˆ1 Rx
i
iR
R
ˆ
2131
2131
2131
PPPP
PPPP
axis-x along PPPP aligns
Rz
k
![Page 140: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/140.jpg)
140
Finding Ry
y
y
y
y
zyx
zyx
zyx
R
zR
yR
xR
zRzRzR
yRyRyR
xRxRxR
jR
xz
xz
xz
RR
RR
RR
.
.
.
0
1
0
...
...
...
ˆ1
jR
R
ˆ
xz
xz
RR
axis- yalong RR aligns
R
x
y
z 2P
3P 1P
z
x
y
3P
1P 2P
Rx
i
Rz
k
Ry
j
![Page 141: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/141.jpg)
141
Problems to be solved:
Schaum’s outline series:
Problems: 6.1
6.2, 6.5, 6.9, 6.10, 6.11, 6.12 Av
6.3, 6.4 R,L 6.6, 6.7, 6.8 MN,P
![Page 142: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/142.jpg)
Transforming Normal Correctly
142
![Page 143: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/143.jpg)
What is the problem
You have known of Normal vectorsNormal vector to a plane is used for
lighting and shading purposeWhen a Plane is transformed, the normal
vector may not be transformed correctly.The programmer needs to specify correct
normal after transformation
143
![Page 144: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/144.jpg)
144
Normal
Surface Normal: unit vector that is locally perpendicular to the surface
![Page 145: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/145.jpg)
145
Why is the Normal important?
It's used for shading — makes things look 3D!
object color only Diffuse Shading
![Page 146: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/146.jpg)
146
Visualization of Surface Normal
± x = Red± y = Green± z = Blue
![Page 147: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/147.jpg)
147
How do we transform normals?
Object SpaceWorld Space
nOS
nWS
![Page 148: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/148.jpg)
6.837 Fall 06 – Durand 148
Transform Normal like Object?
translation? rotation? isotropic scale? scale? reflection? shear?perspective?
![Page 149: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/149.jpg)
149
Transform Normal like Object? translation? rotation? isotropic scale?scale? reflection?shear?perspective?
![Page 150: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/150.jpg)
150
Similitudes
What class of transforms?
TranslationRotation
Rigid / Euclidean
Linear
Affine
Projective
Similitudes
Isotropic Scaling
Scaling
Shear
Reflection
Perspective
IdentityTranslation
RotationIsotropic Scaling
IdentityReflection
a.k.a. Orthogonal Transforms
![Page 151: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/151.jpg)
151
Transformation for shear and scale
IncorrectNormal
Transformation
CorrectNormal
Transformation
![Page 152: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/152.jpg)
152
More Normal Visualizations
Incorrect Normal Transformation Correct Normal Transformation
![Page 153: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/153.jpg)
153
Think about transforming the tangent plane to the normal, not the normal vector
So how do we do it right?
Original Incorrect Correct
nOS
Pick any vector vOS in the tangent plane,how is it transformed by matrix M?
vOSvWS
nWS
vWS = M vOS
![Page 154: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/154.jpg)
154
Transform tangent vector vv is perpendicular to normal n:
nOST vOS = 0
nOST (M-1 M) vOS = 0
nWST = nOS
T (M-1)
(nOST M-1) (M vOS) = 0
(nOST M-1) vWS = 0
nWST vWS = 0
vWS is perpendicular to normal nWS:
nWS = (M-1)T nOS
nOS
vWS
nWS
vOS
Dot product
![Page 155: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/155.jpg)
155
Comment
So the correct way to transform normals is:
But why did nWS = M nOS work for similitudes?Because for similitude / similarity
transforms,
(M-1)T = Me.g. for orthonormal basis:
nWS = (M-1)T nOS
xu
yu
zu
xv
yv
zv
xn
yn
zn
ux
vx
nx
uy
vy
ny
uz
vz
nz
M-1 =M =
Sometimes noted M-T
![Page 156: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/156.jpg)
Rotational Interpolation
156
![Page 157: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/157.jpg)
Camera Interpolation
How to smoothly interpolate a camera between two views ?
157
![Page 158: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/158.jpg)
More about Euler Angles
Durand slideTait Bryan Angles
158
![Page 159: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/159.jpg)
Flight Dynamics
Roll Pitch YawTrai
159
![Page 160: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/160.jpg)
Roll, Pitch, Yaw
160
![Page 161: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/161.jpg)
Interpolation by Euler AngleGimbal LockHow gimbal lock prevented (4th axis)Interpolation by Quaternion
161
![Page 162: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/162.jpg)
162
Hierarchical Modeling
Many graphical objects are structured Exploit structure for
– Efficient rendering– Concise specification of model parameters– Physical realism
Often we need several instances of an object– Wheels of a car– Arms or legs of a figure– Chess pieces
Encapsulate basic object in a function Object instances are created in “standard” form Apply transformations to different instances Typical order: scaling, rotation, translation
![Page 163: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/163.jpg)
163
OpenGL & Hierarchical Model
ABCC
glPushMatrix
– void glPushMatrix(void);
AB
glPushMatrix
– void glPoipMatrix(void);
ABC C
m
glGetFloatv
– void glGetFloatv(GL_MODELVIEW_MATRIX, *m);
ABC
Some of the OpenGL functions helpful for hierarchical modeling are:
![Page 164: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/164.jpg)
164
Scene Graph
A scene graph is a hierarchical representation of a scene We will use trees for representing hierarchical objects
such that:– Nodes represent parts of an object
– Topology is maintained using parent-child relationship
– Edges represent transformations that applies to a part and all the subparts connected to that part
typedef struct treenode {GLfloat m[16]; // Transformationvoid (*f) ( ); // Draw functionstruct treenode *sibling;struct treenode *child;
} treenode;
Scene
Sun Star X
Earth Venus Saturn
Moon Ring
![Page 165: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/165.jpg)
165
Example - Torso
Initializing transformation matrix for node
treenode torso, head, ...;
/* in init function */
glLoadIdentity();
glRotatef(...);
glGetFloatv(GL_MODELVIEW_MATRIX, torso.m);
Initializing pointers
torso.f = drawTorso;
torso.sibling = NULL;
torso.child = &head;
![Page 166: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/166.jpg)
166
Generic Traversal
To render the hierarchy:– Traverse the scene graph depth-first– Going down an edge:
• push the top matrix onto the stack
• apply the edge's transformation(s)
– At each node, render with the top matrix– Going up an edge:
• pop the top matrix off the stack
![Page 167: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/167.jpg)
167
Generic Traversal : Torso
Recursive definitionvoid traverse (treenode *root) {
if (root == NULL) return;
glPushMatrix();
glMultMatrixf(root->m);
root->f();
if (root->child != NULL) traverse(root->child);
glPopMatrix();
if (root->sibling != NULL) traverse(root->sibling);
}
C is really not the right language for this !!
![Page 168: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/168.jpg)
168
Viewing Transformation
![Page 169: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/169.jpg)
169
Viewing Pipeline Revisited
xw
yw
zw
pw
Modeling Transform
WorldCoordinates
Pw
yo
xo
zo
po
GraphicsPrimitives Po
ObjectCoordinates
ye
xe
-ze
pe
Viewing Transform Pe
EyeCoordinates
![Page 170: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/170.jpg)
170
Viewing Transformation in OpenGL To setup the modelview matrix, OpenGL provides the
following function:
y
x
z
eye(eyex, eyey, eyez)
center(centerx, centery, centerz)
up(upx, upy, upz)
gluLookAtgluLookAt(( eyex, eyey, eyezeyex, eyey, eyez, , centerx, centery, centerzcenterx, centery, centerz, , upx, upy, upzupx, upy, upz ))
![Page 171: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/171.jpg)
171
Implementation
We want to construct an Orthogonal FrameOrthogonal Frame such that,
xzy
x
z
eCeCeC
puvnormalizeeC
veC
eyecenternormalizev
eyeOC
...
.
.
.
C.e z
C.O(eye)
center
up(upx, upy, upz)
v
C.e x
C.e y
(1)(1) its origin is the point eyepoint eye
(2)(2) its -z basis vector points towards the point point centercenter(3)(3) the up vectorup vector projects to the up direction (+ve y-axis)
Let CC (for camera) denote this frame. Clearly,
![Page 172: Modeling Transformations](https://reader036.vdocuments.net/reader036/viewer/2022062801/56814380550346895dafff82/html5/thumbnails/172.jpg)
172
Thank You