Upload
vivekgarg
View
213
Download
0
Embed Size (px)
Citation preview
Three-Dimensional Geometric and Modeling Transformations
By
Dr. Rajeev Srivastava
CSE, IIT(BHU)
Computer Graphics
Three-Dimensional Geometric and Modeling Transformations
Some Basics
3D Translations.
3D Scaling.
3D Rotation.
3D Reflections.
Transformations.
Some Basics
Basic geometric types.
Scalars s
Vectors v
Points p
Transformations
Types of transformation:
rotation, translation, scale, Reflections, shears.
Matrix representation
Order
P=T(P)
3D Point
We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented as:
z
y
x
3D Translations.
P is translated to P' by T:
1000
100
010
001
z
y
x
t
t
t Called the translation
matrix T =
6
3D Translations.
11000
100
010
001
1
'
'
'
z
y
x
t
t
t
z
y
x
z
y
x
PTP '
7
3D Translations.
An object is translated in 3D dimensional by transforming each of the defining points of the objects.
3D Translations.
zyx tttT ,,
zyx ,,
',',' zyx
3D Scaling
P is scaled to P' by S:
Called the
Scaling matrix
S =
1000
000
000
000
z
y
x
s
s
s
10
3D Scaling
Scaling with respect to the coordinate origin
11000
000
000
000
1
'
'
'
z
y
x
s
s
s
z
y
x
z
y
x
PSP '
3D Scaling
Scaling with respect to a selected fixed position (xf, yf, zf)
1. Translate the fixed point to origin
2. Scale the object relative to the coordinate origin
3. Translate the fixed point back to its original position
1000
)1(00
)1(00
)1(00
),,(),,(),,(fzz
fyy
fxx
fffzyxfffzss
yss
xss
zyxTsssSzyxT
3D Scaling
3D Reflections
About an axis: equivalent to 180rotation about that axis
14
3D Reflections
1000
0100
0010
0001
zRF
15
3D Shearing
Modify object shapes
Useful for perspective projections:
E.g. draw a cube (3D) on a screen (2D)
Alter the values for x and y by an amount
proportional to the distance from zref
16
3D Shearing
1000
0100
10
01
refzyzy
refzxzx
zshear
zshsh
zshsh
M
17
Shears
1000
0100
010
001
b
a
SH z
[email protected] && 18
Rotation Positive rotation angles produce counterclockwise
rotations about a coordinate axis
Rotation
[email protected] && 20
Coordinate-Axes Rotations
11000
0100
00cossin
00sincos
1
'
'
'
z
y
x
z
y
x
sincos' yxx
cossin' yxy
zz '
PRP z )('
Coordinate-Axes Rotations
xzyx
[email protected] && 22
Coordinate-Axes Rotations
11000
0cossin0
0sincos0
0001
1
'
'
'
z
y
x
z
y
x
sincos' zyy
xx '
PRP x )('
cossin' zzz
[email protected] && 23
Coordinate-Axes Rotations
11000
0cos0sin
0010
0sin0cos
1
'
'
'
z
y
x
z
y
x
sincos' xzz
cossin' xzx
yy '
PRP y )('
[email protected] && 24
General Three-Dimensional Rotations
An object is to be rotated about an axis that is parallel to one of the coordinate axes
1. Translate the object so that the rotation axis coincides with the parallel coordinate axis
2. Perform the specified rotation about that axis
3. Translate the object so that the rotation axis is moved back to its original position
PTRTP x )(' 1
TRTR x )()( 1
[email protected] && 25
General Three-Dimensional Rotations
An object is to be rotated about an axis that is not parallel to one of the coordinate axes
1. Translate the object so that the rotation axis passes through the coordinate origin.
2. Rotate the object so that the axis of rotation coincide with one of the coordinate axes.
3. Perform the specified rotation about that coordinate axis.
4. Apply inverse rotations to bring the rotation axis back to its original orientation.
5. Apply the inverse Translation to bring the rotation axis back to its original position.
26
1 2
2 1 2 1 2 1 2 1
The vector from to is:
, ,x x y y z z
P P
V P P
2 1
2 1
2 1
2 2 2
Unit rotation vector: | | , ,
| |
| |
| |
1
a b c
a x x
b y y
c z z
a b c
u V V
V
V
V
1
1
1
1 0 0
0 1 0
0 0 1
0 0 0 1
x
y
z
T
, ,a b cu
x
y
z
27
Rotating to coincide with axiszu
2 2
2 2
First rotate around axis to lay in plane.
Equivqlent to rotation 's projection on plane around axis.
cos , sin .
We obtained a unit vector ,0, in plane.
x x z
y z x
c b c c d b d
a b c d x z
u
u
w
1 0 0 0
0 0
0 0
0 0 0 1
x
c d b d
b d c d
R
, ,a b cu
x
y
z
u
28
, ,a b cu
x
y
z
,0,a dw
2 2
Rotate counterclockwise around axis.
is a unit vector whose component is , component is 0,
hence component is .
y
x a y
z b c d
w
w
cos , sind a
0 0
0 1 0 0
0 0
0 0 0 1
y
d a
a d
R
29
cos sin 0 0
sin cos 0 0
0 0 1 0
0 0 0 1
z
R
1 1 1x y z y x R T R R R R R T
2
2
2
1 cos cos 1 cos sin 1 cos sin
1 cos sin 1 cos cos 1 cos sin
1 cos sin 1 cos sin 1 cos cos
R
a ab c ac b
ba c b bc a
ca b cb a c
M