Lecture 18
Lecture 18
Lecture 18
3-D Transformations-II
Taqdees A. Siddiqi
[email protected]
Rotation
x' 1 0 0 0 x
y ' 0 cos sin
0 y
.
z ' 0 sin cos 0 z
1 0 0 0 1 1
P` = Rx(θ) . P
Rotation about y-axis
( Sx = Sy = Sz)
Differential Scaling
Sx 0 0 0
0 Sy 0
0
0 0 Sz 0
0 0 0 1
Scaling w.r.t. a fixed position
1 0 0 X f Sx 0 0 0 1 0 0 Xf
0
1 0 Yf 0 S y 0
0 0
1 0 Yf
. .
0 0 1 Z f 0 0 Sz 0 0 0 1 Zf
0 0 0 1 0 0 0 1 0 0 0 1
Composite Transformation
Sx 0 0 (1 S x ) X f
0 Sy 0
(1 S y )Y f
0 0 Sz (1 S z ) Z f
0 0 0 1
Reflection
1 0 0 0
0 1 0
0
0 0 1 0
0 0 0 1
Reflection of points relative to the Y
axis
1 0 0 0
0 1 0
0
0 0 1 0
0 0 0 1
Reflection of points relative to the xy
plane
1 0 00
0 1 0 0
0 0 1 0
0 0 0 1
Shears
Shearing transformations can be used to modify object
shapes
As an example of three-dimensional shearing, the
following transformation produces a z-axis shear:
1 0 a 0
0 1 b
0
0 0 1 0
0 0 0 1
Y-axis shear
1 a 0 0
0
1 0 0
0 c 1 0
0 0 0 1
X-axis shear
1 0 0 0
b
1 0 0
c 0 1 0
0 0 0 1
Computer Graphics
Lecture 18
Rotation w.r.t. y-axis:
P` = Ry(θ) . P
From the drawing and elementary trigonometry, we
can say:
cos(q) = X/D or
D = X /cos(q)
sin(q) = Y/D or
D = Y/sin(q)
where D = hypotenuse
= length of vector
from origin to (x,y)
To rotate to our new point, we just add m to q
For our new point, we know that:
cos ( q + m) = X` / D
sin ( q + m) = Y`/ D
X` = D * cos ( q + m )
Y` = D * sin ( q + m )
We can expand these using the addition formulas
cos ( q + m ) = cos ( q ) * cos ( m ) –
sin( q ) * sin ( m )
X` = D * cos (q + m )
= X * cos(m) – Y*sin(m)
And we can follow a similar approach to find Y`
Y` = D*sin(q+m)
= D*[sin(q) * cos(m) + cos(q) * sin(m)]
= D*sin(q) * cos(m) + D*cos(q) * sin(m)
Y` = [ X/ cos(m)] * sin(q ) *cos(m) +
[Y/sin(m) ] * cos(q ) * sin(m)
= X * sin(q) + Y*cos(q)
So to rotate the point (x,y,z) around the Z axis through
an angle of M degrees, we use:
X` = x*cos(M) – y*sin(M)
Y` = x*sin(M) + y*cos(M)
Z` = z
You see, in the above, we rotate M degrees around the
Z axis (“roll”), moving from the +X axis to the +Y axis
But if you look down on the XY plane from the +Z axis,
this is a –M degree rotation!
you can go through a similar process to calculate the
rotation formula for rotating around the X axis (“pitch”)
and around the Y axis (“yaw”), ending up with:
Roll ( rotate around Z axis):
x` = x * cos(m ) + y* sin(m)
y` = y* cos(m) – x * sin(m)
z` = z
Pitch ( rotate around the X axis):
x` = x
y` = y * cos(m) + z * sin(m)
z` = z * cos(m) – y*sin(m)
Yaw ( rotate about the Y axis):
x` = x * cos(m) – z * sin(m)
y` = y;
z` = x * sin(m) + z * cos(m)
Using Matrices for Rotation
Roll (rotate about the Z axis)
| cos(m) sin(m) 0 0|
| -sin(m) cos(m) 0 0|
| 0 0 1 0|
| 0 0 0 1|
or
P` = Rz(m) . P
Pitch (rotate about the X axis)
|1 0 0 0|
|0 cos(m) sin(m) 0|
|0 -sin(m) cos(m) 0|
|0 0 0 1|
or
P` = Rx(m) . P
Yaw (rotate about the Y axis)
| cos(m) 0 -sin(m) 0|
| 0 1 0 0|
| sin(m) 0 cos(m) 0|
| 0 0 0 1|
or
P` = Ry(m) . P