3D Transformation in Computer Graphics Solved Problems

3D Transformation in Computer Graphics:

Translation:

If any point P(x,y,z) in 3D space is moved to position P'(x’,y’,z’) such that
x’=x+Δx
y’=y+Δy
z’=z+Δz

Δx, Δy ,Δz being the displacement of P in three principal directions x,y,z respectively.
Then we can express this 3D translation in homogenous matrix form as:

3D Transformation in Computer Graphics Solved Problems

Scaling:

The matrix expression for scaling transformation, relative to the coordinate origin will be:

3D Transformation in Computer Graphics Solved Problems

Rotation:

Any 2D rotation transformation is uniquely defined by specifying a centre of rotation and amount of angular rotation, but these two parameters don’t uniquely define a rotation in 3D space because an object can rotate along different circular paths centring a given rotation centre and thus forming different planes of rotation. We need to fix the plane of rotation and that is done by specifying an axis of rotation instead of a centre of rotation. The radius of the rotation path is always perpendicular to the axis of rotation.

Rotation about Z-axis:

If the rotation is carried out about the Z-axis, the coordinates remain unchanged because rotation occurs in planes perpendicular to the Z-axis while x and y coordinates behave the same way as in two dimensions. Rotation of any point P(x,y,z) about the Z-axis by an amount θ is represented by:

3D Transformation in Computer Graphics Solved Problems

Rotation about X-axis:

Here rotation takes place in planes perpendicular to X-axis. Hence x coordinate doesn’t change after rotation while the y and z coordinates are transformed. The expression can be derived similarly as before if we replace the Z-axis in Fig: with X-axis and the other two axes accordingly, maintaining the right-handed coordinate system.

Rotation-about-X-axis

z’=ysinθ+zcosθ
x’=x

Rotation about Y-axis:

We replace Z-axis with Y-axis with the Z and X-axis respectively,

Rotation-about-Y-axis

y’=ycosθ-zsinθ
So, we get,
z’=zcosθ-xsinθ
x’=zsinθ+xcosθ
y’=y

Reflection:

Reflection of objects in 3D occurs through a plane. A real life all the mirrors are planes in 3D space. Just like 3D rotation, there are some standard reflections and arbitrary reflections guided by the orientation of the reflecting plane. Reflection about coordinate planes XY, YZ, and ZX are standard ones and it can be easily derived as only one dimension or coordinate changes in each case.

Reflection about XY Plane:

After reflection the object goes on the opposite side of the reflection plane along the Z direction. So, in terms of coordinates z-coordinates get reversed in sign.

3D-Reflection

x’=x
y’=y
z’=-z

Reflection about YZ Plane:

In this case, after reflection y and z coordinates remain unchanged while the x coordinate gets reversed in sign.

Reflection-about-YZ

x’=-x
y’=y
z’=z

Reflection about ZX Plane:

Here z and x coordinates remain unchanged while the y coordinates get reversed in sign only.

Reflection-about-ZX

x’=x
y’=-y
z’=z

Shearing:

In 3D, we can also generate shears relative to the Z-axis and the result is the change of volume and 3D shape of any object. It is useful in three-dimensional viewing for obtaining general projection transformations.
Example: a Z-axis 3D Shear can be expressed as:
x’=x+az
y’=y+bz
z’=z

The corresponding transformation matrix is:

shear-matrix

An X-axis 3D shear can be expressed as:
x’=x
y’=y+ax
z’z+bx

The corresponding transformation matrix is:

shear-x

Similarly, a Y-axis 3D shear can be expressed as:
x’=x+ay
y’=y
z’z+by

The corresponding transformation matrix is:

shear-y