3D Transformations
3D Transformations
3-D Transformations
3D Coordinate System
• Distance Formula
D = sqrt((x1 – x0)2 + (y1 – y0) 2 +( z1 – z0) 2)
• Equations of Line
– Parametric form:
x = x0+(x1 – x0).t
y = y0+(y1 – y0).t 0≤ t ≤1
z = z0+(z1 – z0).t
– Implicit Form:
y = m1x+b1
z = m2x+b2
y axis
z axis x axis
November 29, 2024 Computer Graphics 10
Vector Fundamentals
• If P(x0,y0,z0) and Q(x1,y1,z1) are two points in space then
PQ = (x1 – xo)I+ (y1 – yo)J+ (z1 – zo)K
y axis
u
v v+u
u+v
u
u u -v
v
u-v
u
2u -3u
K I
Right-Hand
Reference System
Ax + By + cZ – D = 0 form (x0,y0,z0)
November 29, 2024 Computer Graphics 22
Contents
1. 3D Coordinate System
2. Vector Fundamentals
3. 3D Homogeneous Coordinate
4. 3D Geometric Transformations
5. 3D Inverse Transformations
6. 3D Coordinate Transformations
7. Composite transformations
px
M py d
pz
vx
M vy
vz
– Translation
– Scaling
– Rotation
– Reflection
– Shearing
(x, y, z)
(x’, y’, z’)
Translated Position
1 0 0 tx x x
0 y
1 0 ty y
T v P ' P
0 0 1 tz z z
0 0 0 1 1 1
Scaled Position
x
x
z
1 hyx hzx 0
h 1 hzy 0
Sh xy
hxz hyz 1 0
0 0 0 1
– Inverse Rotations: 1
R , p R , p
1
– Inverse Reflections: M plane M plane
– Coordinate Reflections: 1
M plane M plane M plane
1 0 0 a sx 0 0 0 1 0 0 a
0 1 0 b 0 sy 0 0 0 1 0 b
S sx , sy , sz ( a ,b ,c )
0 0 1 c 0 0 sz 0 0 0 1 c
0 0 0 1 0 0 0 1 0 0 0 1
sx 0 0 a.sx a
0 sy 0 b.sy b
0 0 sz c.sz c
0 0 0 1
November 29, 2024 Computer Graphics 70
Exercise 3
Z axis
Aligning vector V with Vector K
Let V = aI+bJ+cK then the alignment can be
performed by following sequence of
operations:
P(a,b,c)
•Rotate V about X-axis by an angle of 1, so
c
that V rotates into upper -half of the xz – V
plane. V’= R1,I(V)
a b
Y axis
•Rotate V’ about Y-axis by an angle of -2,
so that V’ rotates and align with Z – axis.
V”= R - ,J(V ’).
2
X axis
How to get these two angles???
November 29, 2024 Computer Graphics 72
Exercise 3
Z axis
Where 1 0 0 0 b
0 cos sin 1 0
sin 1
b2 c2
R1 , I 1
1
November 29, 2024 Computer Graphics 75
Exercise 3
Z axis
R(0,0,a2+b2+c2)
Step2: Rotate V’ about Y-axis by an angle
Q’(0,0,b2+c2)
of – 2 , so that V’ aligns with +ve Z axis.
V’
V”= R1,I(V) a P’(0,b,c)
Q(a,0,b2+c2) C P(a,b,c)
Let Q’ be projection of Q(a,0,b2+c2) on Z 2 V
axis, Q’↔(0,0, b2+c2 ). If 2 be the angle
that OQ’ makes with +ve Z-axis, then from
O B
OQQ’ a Y axis
sin 2 A
a2 b2 c2
b2 c2
cos 2 X axis
a2 b2 c2
November 29, 2024 Computer Graphics 76
Exercise 3
Where
cos 1 0 sin 2 0 a
0 sin 2
1 0 0 a2 b2 c2
R 2 , J
sin 2 0 cos 2 0 b2 c2
cos 2
0 0 0 1 a2 b2 c2
0 0 0 1 1
b2 c2 a
0 0 a
2 2 2 2 2 2
a b c a b c
0 1 0 0 0
2 2
.
b c
2 2
a b c
0 0
2
a b c 2 2 2
a b c 2 2
1
0 0 0 1
a b2 c2 a b2 c2
2 2 2
0
a b c
0
0
2
a b c 2 2
a b c 2 2 2
2 2 2
a b c 1
November 29, 2024 1 Computer Graphics
78
Exercise 3
Composite Matrix AV,K can be found as
R R 2 , J (Q) R 2 , J * R1 , I ( P )
b2 c2 a 1 0 0 0
0 0 c b
a2 b2 c2 a2 b2 c2 0 2 2
0
b c b2 c2
0 1 0 0 .
b c
a b c2
2
0
0 0 0
a2 b2 c2 a 2 b2 c2 b2 c2 b2 c2
0 0 0 1 0 0 0 1
ab ac
a V 0
V 0 0 1 0 0 0 V V
V c b
0 0 0 c b
0 1 0 0 . 0 b2 c2
a b c where
0
0 0 0 a b c V a2 b2 c2
V V 0
0
0 0 1 0 0 0 1 V V V
0 0 0 1
A 1V , K ( R 2 , J . R1 , I ) 1
1 1
R 1 , I .R 2 ,J
T T
R 1 , I .R 2 ,J
T
( R 2 , J . R1 , I )
T
( AV , K )
T
A V ,K
Thus P5 = T-1-P0(P4)
= T-1-P0.A-1V,K(P3)
= T-1-P0.A-1V,K. R,K(P2)
= T-1-P0.A-1V,K. R,K. AV,K(P1)
= T-1-P0.A-1V,K. R,K. AV,K. T-P0(P)
2 1 1 1 1 1 2
0 1
2 2 2 2 2 2
1 2 2 2 2 2 2
2 2 2 4 2
1
2 2
R450 , L
1
4 4 4 A' B' C ' D' 4 4 2
2 2 2 2 2 2 2 2
2 4 2
2 4 4 4 0
0 0 0 1 4 4 2
1 1 1 1
Thus P5 = T-1-R0(P4)
= T-1-R0.A-1N,K(P3)
= T-1-R0.A-1N,K. MXY(P2)
= T-1-R0.A-1N,K. MXY. AN,K(P1)
= T-1-R0.A-1N,K. MXY. AN,K. T-R0(P)
1 2 2
0
3 3 3
2 1 2
0
M N ,P0 3 3 3
2 2 1
0
3 3 3
0 0 0 1