Three-Dimensional Transformations

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 43

THREE-DIMENSIONAL

TRANSFORMATIONS
Introduction
 We can create a variety of pictures and graph forms.
 We need altering or manipulation displays.
 We need to change the size of an object or graph.
 Various manipulations are carried out by applying
appropriate geometric transformations.
 Displayed objects are defined by sets of coordinate
points. Geometric transformations are procedures for
calculating new coordinate positions for these points.
Why are transformations useful?
 Define objects only once, then transform to compose
bigger objects

 Translations, rotations, scaling, …


Why are transformations useful?
 Define motif, then construct object
from motif
Use 8 times
Why are transformations useful?

 Computer animation
• Translate / rotate / move object over time
Cartesian coordinate system
3D Point Representation
 A 3D point P is represented in homogeneous
coordinates by a 4-dimensional vector:

X
P= x y z 1
Y
P=
Z
1
Transformation Matrix
Given two frames in an affine space of dimension n, we can find a
(n+1) x (n+1) matrix that converts the coordinates of a point in the
first frame to the coordinates of the same point in the second
frame. The operation are called transformation. The matrix is
called transformation matrix. In 3D space, for example, the
g e n e r a l f o r m o f t h e m a t r i x i s

e1,1 e1,2 e1,3 0


e2,1 e2,2 e2,3 0
e3,1 e3,2 e3,3 0
e4,1 e4,2 e4,3 1
3D Translation
y
y

z z

Ty
Tz
X X
TX
3D Translation
Geometric translation equations can be expressed in
terms of transformation matrices.

1 0 0 0

x’ y’ z’ 1 x y z 1 0 1 0 0
=
0 0 1 0

Tx Ty Tz 1

x’ = x + Tx y’ = y + Ty z’ = z + Tz
3D Translation
 An object is translated in 3D by transforming
each of its defining points.
 We obtain the inverse of the translation
matrix by negating the translation distances
Tx,Ty and Tz.
• this produces a translation in the opposite
direction, and the product is the identity matrix.
Translation a point
y

(x’, y’, z’)


(x, y, z)

Translating a point with translation vector (Tx, Ty, Tz)


Translate an object
y

Translating an object with translation vector (Tx, Ty, Tz)


3D Scaling
y
y
z
z
Sz

X Sy
X
SX
3D Scaling
 The matrix operation for scaling in 3D
relative to the origin coordinate is

Sx 0 0 0

x’ y’ z’ 1 x y z 1 0 Sy 0 0
=
0 0 Sz 0

0 0 0 1

Where Sx,Sy, and Sz are assigned any positive values. and we obtain:
x’ = x . Sx y’ = y . Sy z’ = z . Sz
3D Scaling
 As in 2D, if the object is not centered at the origin (0, 0, 0) the
scaling transformation causes both size change and
movement of the object.
 Scaling about a fixed point P (x0,y0,z0) can be accomplished
by the following:
1. translating P to the origin
2. scaling the object
3. translating P back to original position.
so the composite matrix is
T(-x0,-y0,-z0)*(S(Sx,Sy,Sz))*(T(x0,y0,z0))
 Inverse Scaling: replace Sx with 1/Sx, Sy with 1/Sy, and Sz
with 1/Sz, then S(S-1) = 1
3D Scaling
y

Doubling the size of an object with scaling matrix, also moves


the object farther from the origion
3D Scaling

y
y

z
x z
In the beginning Step 1
3D Scaling

y
y

x
x
z Step 4
Step 3
z
3D Rotation
 3D Rotation is more complicated than 2D.

 we must specify an axis of rotation.

 In 2D the axis of rotation is always perpendicular


to the xy plane, i.e., the Z axis.

 in 3D, the axis of rotation can have any spatial


orientation.
3D Rotation about the z-axis

Y
Y

qy
Z Z

X X
3D Rotation about the z-axis

• Z-axis rotation is identical to the 2D case

cosθ sinθ 0 0

x’ y’ z’ 1 x y z 1 -sinθ cosθ 0 0
=
0 0 1 0
0 0 0 1

x’ = x cosθ – y sinθ y’ = x sinθ + y cosθ z’ = z


3D Rotation about the x-axis

Y Y
qx
Z Z

X X
3D Rotation about the x-axis

1 0 0 0

x’ y’ z’ 1 x y z 1 0 cosθ sinθ 0
=
0 -sinθ cosθ 0

0 0 0 1

y’ = y cosθ – z sinθ z’ = y sinθ + z cosθ x’ = x


3D Rotation about the y-axis

Y Y

Z Z

qz
X X
3D Rotation about the y-axis

cosθ 0 -sinθ 0

0 1 0 0
x’ y’ z’ 1 = x y z 1
sinθ 0 cosθ 0

0 0 0 1

z’ = z cosθ – x sinθ x’ = z sinθ + z cosθ y’ = y


Rotation about x-axis
Rotation about y-axis
Rotation about z-axis
Rotation About a Fixed Point
 Move fixed point to origin
 Rotate
 Move fixed point back
 M= T(-pf) R(θ) T(pf)
Rotation about an Arbitrary Axis
 This is similar to 2D rotation about an arbitrary point.
 The general procedure is as follows:
• Perform transformations which align rotation axis with
one of coordinate axis (x, y, z) .
• Perform rotation about the axis.
• Do inverse of (1).
Rotation about an Arbitrary Axis
Composite 3D Transformations
 Like 2D transformations, 3D transformations, in general, are not
commutative.

 Transformations of one type (e.g. rotation) will not, in general, be


commutative with transformations of another type
(e.g. translation).

 Furthermore, a rotation about one axis will not, in general, be


commutative with a rotation about a different axis.

 a rotation of 90˚ about the x-axis, followed by a rotation of 90˚


about the y-axis, will not achieve the same thing as a rotation of
90˚ about the y-axis, followed by a rotation of 90˚ about the
x-axis.
3D Reflections
 Reflections can be performed relative to a selected axis
or relative to a selected plane.

 A reflection with respect to an axis is equivalent to a 180˚


rotation about that axis.

 A reflection with respect to one of the coordinate planes


(i.e. xy, xz, yz) is equivalent to a conversion between a
right-handed frame and a left-handed frame.
3D Reflections
 A reflection about the xy plane reverses the sign of
the z-coordinates, leaving the x and y coordinates
unchanged.

1 0 0 0
0 1 0 0
RFz = 0 0 -1 0
0 0 0 1
3D Reflections
 Likewise, a reflection about the yz plane reverses
the sign of the x-coordinates, and a reflection about
the xz plane reverses the sign of the y-coordinates.

-1 0 0 0 1 0 0 0
0 1 0 0 0 -1 0 0
RFx = 0 0 1 0 RFy = 0 0 1 0
0 0 0 1 0 0 0 1
3D Shears
Y
Y

X
X

Z
Z
3D Shears
 A shear operation in 3D is a fairly straightforward
extension of a shear operation in 2D
 A 3D shear relative to the z-axis is accomplished by:

1 0 shzx 0
0 1 shzy 0
M-Shear z = 0 0 1 0
0 0 0 1
3D Shears
 A 3D shear relative to the x-axis and y-axis are
accomplished by:

1 0 0 0 1 shyx 0 0
shxy 1 0 0 0 1 0 0
M-Shearx = M-Sheary =
shxz 0 1 0 0 shyz 1 0
0 0 0 1 0 0 0 1
References
 http://www.cs.kuleuven.ac.be/~graphics/H331/

 http://www.siggraph.org/education/aterials/HyperGraph

 http://www.cosc.brocku.ca/Offerings/3P98/course/lectures/2d_3d_xforms/

 Donald Hearn, M. Pauline Baker Computer Graphics (0-13-165598-1)


The END

You might also like