T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Computer Graphics and Programming
Moving Coordinate(Animation)
Lecture 6
Jeong-Yean Yang
2020/10/22
1
T&C LAB-AI
Moving Coordinate Transform
1
2
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Smooth Coordinate Transform
• Continuous Transformation from H to H’
– Translation Rotation
3
H
H’
'
( 0
1)
d
d
X
X
e
X
X
X
X
Ke
K
'
( 0
1)
d
d
e
Ke
K
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Ex) uWnd-43-MC-Translation
4
'
( 0
1)
d
d
X
X
e
X
X
X
X
Ke
K
Trans (0,0,0)(3,0,0)
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Ex) uWnd-44-MC-Rotation
5
'
( 0
1)
d
d
e
Ke
K
Rot (0,0,0) (30,50,0)
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Ex) Translation + Rotation
6
'
d
d
Trans
X
X
e
X
X
X
X
Ke
H
'
d
d
Rot
e
Ke
H
'
Trans
Rot
H
H
H
• Translation and Rotation for Continuous Transform in
every step.
T&C LAB-AI
Quaternion as
Homogeneous Transform
2
7
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Quaternion for Homogeneous Transform
New classs, hQuat
• Matrix Multiplication is easier that Vector calculus
• hQuat has the feature of Quaternion
8
2
2
2
2
0
1
2
3
1 2
0
3
1 3
0
2
2
2
2
2
1 2
0
3
0
1
2
3
2
3
0 1
2
2
2
2
1 3
0
2
2
3
0 1
0
1
2
3
2(
)
2(
)
0
2(
)
2(
)
0
2(
)
2(
)
0
0
0
0
1
ˆ
ˆ
'
q
q
q
q
q q
q q
q q
q q
q q
q q
q
q
q
q
q q
q q
H
q q
q q
q q
q q
q
q
q
q
v
Hv
0
1
2
3
q
q
q i
q j
q k
ˆ
ˆ
ˆ ˆ ˆ
ˆ ˆ
'
cos
(1 cos )(
)
sin
v
v
v u u
u v
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Ex) uWnd-46-MC-Quaternion
hMat.h
9
1
2
3
hQuat(angle,axis)
hQuat(angle, ,
,
)
q q q
hMat operator*(hMat)
hMat h;
hQuat q;
h = q*h;
p.14, Quaternion
ˆ
ˆ
ˆ
( , )
cos
sin
, | | 1
2
2
if q
s u
u
u
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
hQuat(Quaternion) hMat(H matrix)
10
2
2
2
2
0
1
2
3
1 2
0
3
1 3
0
2
2
2
2
2
1 2
0
3
0
1
2
3
2
3
0 1
2
2
2
2
1 3
0
2
2
3
0 1
0
1
2
3
2(
)
2(
)
0
2(
)
2(
)
0
2(
)
2(
)
0
0
0
0
1
q
q
q
q
q q
q q
q q
q q
q q
q q
q
q
q
q
q q
q q
H
q q
q q
q q
q q
q
q
q
q
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Ex)uWnd-46-MC-Quaternion
• Rotation along (1,1,1) vector is very Easy.
• See Result of HW 10.
11
z
x
y
1
1
1
u=(1,1,1)
T&C LAB-AI
Inverse Homogeneous Transform
3
12
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Back to Definition of H
• R: Rotation
• T: Translation
• 1: homogeneous factor (Distance)
• P: projection Used in 3D vision and Graphics.
•
Not for Robotics.
13
1
R
T
H
P
1
x
X
'
1
1
1
1
R T
R T
x
Rx T
X
HX
X
P
P
Px
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Inverse of Homogeneous Transform
14
0
1
R T
H
3 3
1
4 4
0
0
1
0
1
R T
a
b
I
HH
I
c
d
1
Ra Tc
Rb Td
HH
I
c
d
0,
1
c
d
3 3 3 3
3 3 3 1
3 1
3 3
1
0
0
1
0
1
R a
R b
T
I
HH
3 3 3 3
3 3
3 3 3 1
3 1
3 1
0
R a
I
R b
T
1
2
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Inverse of Rotation Matrix
15
3 3 3 3
3 3
1
3 3
R a
I
R
a
Remind rotation matrix
1
1
cos
sin
cos
sin
sin
cos
sin
cos
T
x
x
x
R
R
R
1
T
R
R
• When inverse matrix is equal to Transpose,
– It is called “Orthogonal transform”
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Inverse of Homogeneous Transform
16
3 3 3 1
3 1
3 1
0
R b
T
3 3 3 1
3 1
1
3 1
3 3
3 1
3 3
3 1
T
R b
T
b
R
T
R
T
1
0
1
0
1
T
T
R
T
R
R T
H
H
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Inverse Homogeneous Transform
hMat::Inv()
17
1
0
1
T
T
R T
R
H
v[0]
v[4]
v[8]
v[1]
v[5]
v[9]
v[2]
v[6]
v[10]
v[3]
v[7]
v[11]
v
v[12]
v[13]
v[
5]
14]
[1
H
[0]
[4]
[8]
[0]
[1]
[2]
[1]
[5]
[9] ,
[4]
[5]
[6]
[2]
[6]
[10]
[8]
[9]
[10]
T
v
v
v
v
v
v
R
v
v
v
R
v
v
v
v
v
v
v
v
v
T
R
T
T
R T
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Inverse Trans(x,y,z) = Trans(-x,-y,-z)
ex) uWnd-48-MC-Inv
• Inverse transform
is useful for
complex
multiplication
18
1
1
Trans
Rot
Trans
Trans
Rot
Trans
Trans
Rot
Trans
H
H
H
H
H
H
H
H
H
H
1
1)
(x, y, z) RotZ(q) H
(
,
,
)
2)
H
(
,
,
) RotZ(q) H
(
,
,
)
pivot
trans
trans
pivot
trans
trans
case H
H
x
y
z
case
H
x
y
z
x
y
z
Remind pivot,
Ch5. pp. 29
T&C LAB-AI
Inverse Perspective Matrix
One of the Most Advanced Methods in 3D Graphics
4
19
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Can We Get 3D position by clicking 2D?
• From 2D into 3D?
• Ans: Extra Information is
required.
– Here, z = 0 plane.
20
Click
here
onLButtonDown
2D point
Inverse
Perspective
Matrix
Is it
Possible?
3D point
3
2
2
3
3
???
2
3
x
x
R
y
R
y
z
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Inverse Perspective Matrix
21
cot( / 2)
cot( / 2)
cot( / 2)
0
0
0
/
/
/
y
0
cot( / 2)
0
0
cot( / 2)
cot( / 2)
2
2
2
1
0
0
1
0
0
1
0
1
p
x
x
W H
z
x
W H
W H
y
y
z
v
Pv
n
f
nf
n
f
nf
z
n
f
nf
z
n
f
n
f
n
f
n
f
n
f
n
f
z
z
1
/
0
0
0
cot( / 2)
1
0
0
0
cot(
cot( / 2)
/
cot( / 2)
2
/ 2)
0
0
0
1
0
0
2
1
2
p
x
x
W H
y
y
v
v
n
f
nf
z
z
n
f
n
f
z
W H
P
n
f
n
f
nf
nf
Normalized
2D vector
Inverse Perspective Matrix
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Remind Projection Process
22
1
1
1
1
1
'
'
'
'
p
g
p
p
g
p
p
v
Hv
v
Pv
v
Sv
v
S v
v
P v
v
H v
H P v
Projection
Inverse
Projection
1
Process 1) '
p
v
P v
1
Process2)
'
v
H v
H: T, R for camera walk
• Process 0: Scaling [-1, 1] space into [640,480]
1
Process 0)
p
g
v
S v
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Process 1
• Click information only has 2Dim. Position,
– Assume that ‘h’ is needed by next calculation
– Assume that Zp is zero( It will be compensated later)
23
1
/
/
0
0
0
cot( / 2)
cot( / 2)
1
1
0
0
0
cot( / 2)
cot( / 2)
0
0
0
1
0
1
2
2
'
0
0
2
p
p
p
p
p
W H
W H
P
n
f
n
f
n
f
h
nf
n
x
x
x
y
y
y
v
f
nf
v
z
h
h
Click
here
(
,
)
p
p
x
y
1
Process 1) '
p
v
P v
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Process 2
24
1
Process2)
'
v
H v
1
Process 1) '
p
v
P v
11
12
13
14
11
12
13
14
21
22
23
24
21
22
23
24
31
32
33
34
31
32
33
34
/
cot( / 2)
1
cot( / 2)
0
0
0
0
1
0
0
1
1
0
1
2
p
x
y
p
W H
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
h
n
f
h
x
t
x
x
t
y
y
v
h
nf
y
z
31
32
33
31
32
33
31
32
33
34
34
34
2
...
...
...
...
2
z-h
1
2
2
2
z
x
y
z
x
y
z
x
y
z
t
h t
h t
h t
h t
h t
n
f
h
nf
n
f
n
f
h
h
nf
nf
n
f
h
nf
n
f
h
h t
h t
h t
h t
h
n
h
f
Z=0
Unknown
value
1
H
1
H
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
25
31
32
33
34
1
1
1
2
0
1
2
z-h
/ 2
/ 2
/ 2
1
1
/ 2
/ 2
/
2
2
1
x
y
z
x
x
y
y
z
z
x
y
z
n
f
h
nf
n
f
h
n
h t
h t
h t
z
t
x
x
t
z
t
y
y
t
z
v
H
H
t
z
t
z
t
z
t
z
v
H
z
f
t
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Click
Here for move
Ex) uWnd-49-MC-Invp
This example is one of the most complex examples
in the field of Graphics
• Right click for Movement
26
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
Ex) uWnd-49-MC-Invp
uCam::Inv()
27
0
p
p
p
x
y
v
h
,
0
plane z
(0,0)
(640,480)
Click coordinate of
onLButtonDown()
Inverse scaling of
[-1,1] [-320,320]
1
Process 1) '
p
v
P v
T&C LAB-AI
Dept. of Intelligent Robot Eng. MU
Robotics
28
31
2
3
34
2
3
3
z-
2
h
x
y
z
h t
h
n
f
z
h
n
t
h t
f
(
2
/ 2
/ 2
/
)
1
2
2
1
x
x
y
y
z
z
n
f
t
x
t
z
t
y
h
t
z
v
t
z
z
z
f
t
n
1
Process2)
'
v
H v
Right mouse click changes Xd
0
0
T
p
p
p
v
x
y
h
z