Chapter 6

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Three-Dimensional Graphics

The three-dimensional transformations are extensions of two-dimensional transformation. In 2D


two coordinates are used, i.e., x and y whereas in 3D three co-ordinates x, y, and z are used.
For three dimensional images and objects, three-dimensional transformations are needed. These
are translations, scaling, and rotation. These are also called as basic transformations are
represented using matrix. More complex transformations are handled using matrix in 3D.
The 2D can show two-dimensional objects. Like the Bar chart, pie chart, graphs. But some more
natural objects can be represented using 3D. Using 3D, we can see different shapes of the object
in different sections.
In 3D when a translation is done, we need three factors for rotation also, it is a component of
three rotations. Each can be performed along any three Cartesian axis. In 3D also we can
represent a sequence of transformations as a single matrix.
Computer Graphics uses CAD. CAD allows manipulation of machine components which are 3
Dimensional. It also provides automobile bodies, aircraft parts study. All these activities require
realism. For realism 3D is required. In the production of a realistic 3D scene from 2D is tough. It
requires three dimensions, i.e., depth.
3D Geometry
Three-dimension system has three axis x, y, z. The orientation of a 3D coordinate system is of
two types. Right-handed system and left-handed system.
In the right -handed system thumb of right- hand points to positive z-direction and left- hand
system thumb point to negative two directions. Following figure show right-hand orientation of
the cube.

Using right-handed system co-ordinates of corners A, B, C, D of the cube


Point A         x, y, z Point C         0, y, 0
Point B         x, y, 0 Point D         0, y, z
Producing realism in 3D: The three-dimensional objects are made using computer graphics. The
technique used for two Dimensional displays of three-Dimensional objects is called projection.
Three Dimensional Models
The techniques for generating different images of a solid object depend upon the type of object.
Two viewing techniques are available for viewing three-dimensional objects.
 Geometry: It is concerned with measurements. Measurement is the location of a point
concerning origin or dimension of an object.
 Topological Information: It is used for the structure of a solid object. It is mainly
concerned with the formation of polygons with the help of points of objects or the
creation of the object with polygons.
3D Translation
A 3D Translation process contains the x-axis, y-axis, and z-axis. We can move any object from
one place to another without changing the shape of the object.
For Example-
Translation of a Point: If we want to translate a point from P (x0, y0, z0) to Q (x1, y1, z1), then we
have to add Translation coordinates (Tx, Ty, Tz) with original coordinates.

We can also represent the 3D Translation in matrix form-

We can apply Translation on the following objects-

 Line
 Rectangle
 Polygon
 Square

3D Translation Matrix Representation:


The above Translation is also shown in the form of 3 x 3 matrix-

Here Translation coordinates (Tx, Ty, Tz) are also called “Translation or Shift Vector.”
Example: A Point has coordinates P (1, 2, 3) in x, y, z-direction. Apply the translation with a
distance of 2 towards x-axis, 3 towards y-axis, and 4 towards the z-axis. Find the new
coordinates of the point?
Solution: We have,
Point P = (x0, y0, z0) = (1,2,3)
Shift Vector = (Tx, Ty, Tz)
Let us assume the new coordinates of P = (x1, y1, z1)
Now we are going to add translation vector and given coordinates, then
X1 = x0 + Tx = (1 + 2) = 3
Y1 = y0 + Ty = (2 + 3) = 5
Z1 = z0 + Tz = (3 + 4) = 7
Thus, the new coordinates are = (3, 5, 7)
3D Rotation
The 3D rotation is different from 2D rotation. In 3D Rotation we also have to define the angle of
Rotation with the axis of Rotation.
For Example- Let us assume,
The initial coordinates of an object = (x0, y0, z0)
The Initial angle from origin = β
The Rotation angle = θ
The new coordinates after Rotation = (x1, y1, z1)
In Three-dimensional plane we can define Rotation by following three ways-
 X-axis Rotation: We can rotate the object along x-axis. We can rotate an object by using

following equation-
We can represent 3D rotation in the form of matrix-

   

 Y-axis Rotation: We can rotate the object along y-axis. We can rotate an object by using

following equation-
We can represent 3D rotation in the form of matrix-

   
 Z-axis Rotation: We can rotate the object along z-axis. We can rotate an object by using

following equation-
We can represent 3D rotation in the form of matrix-

   
Example: A Point has coordinates P (2, 3, 4) in x, y, z-direction. The Rotation angle is 90
degrees. Apply the rotation in x, y, z direction, and find out the new coordinates of the point?
Solution: The initial coordinates of point = P (x0, y0, z0) = (2, 3, 4)
Rotation angle (θ) = 90°
For x-axis-
Let the new coordinates = (x1, y1, z1) then,
x1= x0 = 2
y1= y0 x cosθ – z0 x sinθ = 3 x cos90°– 4 x sin90° = 3 x 0 – 4 x 1 = -4
z1= y0 x sinθ + z0 x cosθ = 3 x sin90°+ 4 x cos90° = 3 x 1 + 4 x 0 = 3
The new coordinates of point = (2, -4, 3)
For y-axis-
Let the new coordinates = (x1, y1, z1) then,
X1= z0 x sinθ + x0 x cosθ = 4 x sin90° + 2 x cos90° = 4 x 1 + 2 x 0 = 4
y1= y0 = 3
z1= y0 x cosθ – x0 x sinθ = 3 x cos90°– 2 x sin90° = 3 x 0 – 4 x 0 = 0
The new coordinates of point = (4, 3, 0)
For z-axis-
Let the new coordinates = (x1, y1, z1) then,
x1= x0 x cosθ – y0 x sinθ = 2 x cos90° – 3 x sin90° = 2 x 0 + 3 x 1 = 3
y1= x0 x sinθ + y0 x cosθ = 2 x sin90° + 3 x cos90° = 2 x 1 + 3 x 0 = 2
z1= z0 =4
The New Coordinates of points = (3, 2, 4)

3D Scaling
The 2D and 3D scaling are similar, but the key difference is that the 3D plane also includes the z-
axis along with the x and y-axis.

In scaling, we can expend or compress the size of any object. We can apply scaling on the object
by multiplying the original coordinates with scaling factors.

The term scaling factor is used to define whether the size of the object is increased or decreased.
We can represent the scaling factor by ‘Sx’ for the x-axis, ‘Sy’ for the y-axis, and ‘Sz’ for the z-
axis.The increment and decrement of an object is depends on two conditions. They are-

 If scaling factor (Sx, Sy, Sz) > 1, then the size of the object increased.
 If scaling factor (Sx, Sy, Sz) < 1, then the size of the object decreased.

For Example: Let us assume,

The initial coordinates of object = P (x 0, y0, Scaling factor for y-axis = Sy


z0)
Scaling factor for z-axis = Sz
Scaling factor for x-axis = Sx
The coordinates after Scaling = Q (x1, y1, z1)
We can represent the 3D Scaling in the form of equation-

 X1 = x0. Sx
 Y1 = y0. Sy
 Z1 = z0. Sz
Matrix representation of 3D Scaling-

Example: A 3D object that have coordinates points P(1, 4, 4), Q(4, 4, 6), R(4, 1, 2), T(1, 1, 1)
and the scaling parameters are 3 along with x-axis, 4 along with y-axis and 4 along with z-axis.
Apply scaling to find the new coordinates od the object?

Solution: we have,

 The initial coordinates of object = P (1, 4, 4), Q (4, 4, 6), R (4, 1, 2), S (1, 1, 1)
 Scaling factor along with x-axis (Sx) = 3
 Scaling factor along with y-axis (Sy) = 4
 Scaling factor along with z-axis (Sz) = 4
 Let the new coordinates after scaling = (x1, y1, z1)
For coordinate P- x1 = x0 x Sx = 4 x 3 = 12
y1 = y0 x Sy = 4 x 4 = 16
x1 = x0 x Sx = 1 x 3 = 3
z1 = z0 x Sz = 6 x 4 = 24
y1 = y0 x Sy = 4 x 4 = 16
The new coordinates = (12, 16, 24)
z1 = z0 x Sz = 4 x 4 = 16
The new coordinates = (3, 16, 16) For coordinate R-
x1 = x0 x Sx = 4 x 3 = 12
For coordinate Q-
y1 = y0 x Sy = 1 x 4 = 4 x1 = x0 x Sx = 1 x 3 = 3
z1 = z0 x Sz = 2 x 4 = 8 y1 = y0 x Sy = 1 x 4 = 4
The new coordinates = (12, 4, 8) z1 = z0 x Sz = 1 x 4 = 4
The new coordinates = (3, 4, 4)
For coordinate S-

Thus, the new coordinates after scaling = P (3, 16, 16), Q (12, 16, 24), R (12, 4, 8), S (3, 4, 4).

3D Reflection

The Reflection is a mirror image of the original object. We can differentiate 2D and 3D
reflection by adding Z-axis. The Z-axis shows the depth of the surface. In the Reflection process,
the size of the object does not change.

We can represent Reflection by using the following three ways-

 Reflection along with xy Plane: In the xy plane reflection, the value of z is negative.

x1 = x0 y1 = y0 z1 = -z0

 Reflection along with xz Plane: In the xz plane reflection the value of y is negative.

x1 = x0 y1 = -y0 z1 = z0


 Reflection along with yz Plane: In the yz plane reflection the value of x is negative.

x1 = -x0 y1 = y0 z1 = z0

Example: A 3D triangle with coordinates points P (4, 5, 2), Q (7, 5, 3), R (6, 7, 4). Apply
reflection on XY plane and find the new coordinates of triangle?

Solution: We have,

The initial coordinates of triangle = P (4, 5, 2), Q (7, 5, 3), R (6, 7, 4)

Reflection Plane = xy

Let the new coordinates of triangle = (x1, y1, z)

For Coordinate P (4, 5, 2)- For Coordinate Q (7, 5, 3)-


X1 = x0 = 4
X1 = x0 = 7
y1 = y0 = 5
Y1 = y0 = 5
z1 = -z0= -2
Z1 = -z0= -3
The new coordinates = (4, 5, -2)
The new coordinates = (7, 5, -3)
For Coordinate P (6, 7, 4)-

You might also like