by Jesmin Akther | Aug 31, 2021 | Computer Graphics
Three Dimensional Graphics
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 require three dimension, 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 B x, y, 0
Point C 0, 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. Several types of projection are available, i.e.,
- Parallel Projection
- Perspective Projection
- Orthographic Projection
1. Parallel Projection:
In this projection point on the screen is identified within a point in the three-dimensional object by a line perpendicular to the display screen. The architect Drawing, i.e., plan, front view, side view, elevation are nothing but lines of parallel projections.
2. Perspective Projection:
This projection has a property that it provides idea about depth. Farther the object from the viewer, smaller it will appear. All lines in perspective projection converge at a center point called as the center of projection.
3. Orthographic Projection: It is simplest kind of projection. In this, we take a top, bottom, side view of the object by extracting parallel lines from the object.
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.
Three Dimensional Transformations
The geometric transformations play a vital role in generating images of three Dimensional objects with the help of these transformations. The location of objects relative to others can be easily expressed. Sometimes viewpoint changes rapidly, or sometimes objects move in relation to each other. For this number of transformation can be carried out repeatedly.
Translation
It is the movement of an object from one position to another position. Translation is done using translation vectors. There are three vectors in 3D instead of two. These vectors are in x, y, and z directions. Translation in the x-direction is represented using Tx. The translation is y-direction is represented using Ty. The translation in the z- direction is represented using Tz.
If P is a point having co-ordinates in three directions (x, y, z) is translated, then after translation its coordinates will be (x1 y1 z1) after translation. Tx Ty Tz are translation vectors in x, y, and z directions respectively.
x1=x+ Tx
y1=y+Ty
z1=z+ Tz
Three-dimensional transformations are performed by transforming each vertex of the object. If an object has five corners, then the translation will be accomplished by translating all five points to new locations. Following figure 1 shows the translation of point figure 2 shows the translation of the cube.


Matrix for translation

Matrix representation of point translation
Point shown in fig is (x, y, z). It become (x1,y1,z1) after translation. Tx Ty Tz are translation vector.

Example:
A point has coordinates in the x, y, z direction i.e., (5, 6, 7). The translation is done in the x-direction by 3 coordinate and y direction. Three coordinates and in the z- direction by two coordinates. Shift the object. Find coordinates of the new position.
Solution: Co-ordinate of the point are (5, 6, 7)
Translation vector in x direction = 3
Translation vector in y direction = 3
Translation vector in z direction = 2
Translation matrix is

Multiply co-ordinates of point with translation matrix

= [5+0+0+30+6+0+30+0+7+20+0+0+1] = [8991]
x becomes x1=8
y becomes y1=9
z becomes z1=9
Scaling
Scaling is used to change the size of an object. The size can be increased or decreased. The scaling three factors are required Sx Sy and Sz.
Sx=Scaling factor in x- direction
Sy=Scaling factor in y-direction
Sz=Scaling factor in z-direction

Matrix for Scaling

Scaling of the object relative to a fixed point
Following are steps performed when scaling of objects with fixed point (a, b, c). It can be represented as below:
- Translate fixed point to the origin
- Scale the object relative to the origin
- Translate object back to its original position.
In figure (a) point (a, b, c) is shown, and object whose scaling is to done also shown in steps in fig (b), fig (c) and fig (d).




Scaling
Scaling is used to change the size of an object. The size can be increased or decreased. The scaling three factors are required Sx Sy and Sz.
Sx=Scaling factor in x- direction
Sy=Scaling factor in y-direction
Sz=Scaling factor in z-direction

Matrix for Scaling

Scaling of the object relative to a fixed point
Following are steps performed when scaling of objects with fixed point (a, b, c). It can be represented as below:
- Translate fixed point to the origin
- Scale the object relative to the origin
- Translate object back to its original position.
In figure (a) point (a, b, c) is shown, and object whose scaling is to done also shown in steps in fig (b), fig (c) and fig (d).




Inverse Transformations
These are also called as opposite transformations. If T is a translation matrix than inverse translation is representing using T-1. The inverse matrix is achieved using the opposite sign.
Example1: Translation and its inverse matrix
Translation matrix

Inverse translation matrix

Example2: Rotation and its inverse matrix

Inverse Rotation Matrix

Reflection
It is also called a mirror image of an object. For this reflection axis and reflection of plane is selected. Three-dimensional reflections are similar to two dimensions. Reflection is 180° about the given axis. For reflection, plane is selected (xy,xz or yz). Following matrices show reflection respect to all these three planes.
Reflection relative to XY plane


Reflection relative to YZ plane

Reflection relative to ZX plane

Shearing
It is change in the shape of the object. It is also called as deformation. Change can be in the x -direction or y -direction or both directions in case of 2D. If shear occurs in both directions, the object will be distorted. But in 3D shear can occur in three directions.
Matrix for shear




by Jesmin Akther | Aug 31, 2021 | Computer Graphics
Introduction of Transformations
Computer Graphics provide the facility of viewing object from different angles. The architect can study building from different angles i.e.
- Front Evaluation
- Side elevation
- Top plan
A Cartographer can change the size of charts and topographical maps. So if graphics images are coded as numbers, the numbers can be stored in memory. These numbers are modified by mathematical operations called as Transformation.
The purpose of using computers for drawing is to provide facility to user to view the object from different angles, enlarging or reducing the scale or shape of object called as Transformation.
- Each transformation is a single entity. It can be denoted by a unique name or symbol.
- It is possible to combine two transformations, after connecting a single transformation is obtained, e.g., A is a transformation for translation. The B transformation performs scaling. The combination of two is C=AB. So C is obtained by concatenation property.
There are two complementary points of view for describing object transformation.
- Geometric Transformation: The object itself is transformed relative to the coordinate system or background. The mathematical statement of this viewpoint is defined by geometric transformations applied to each point of the object.
- Coordinate Transformation: The object is held stationary while the coordinate system is transformed relative to the object. This effect is attained through the application of coordinate transformations.
An example that helps to distinguish these two viewpoints:
The movement of an automobile against a scenic background we can simulate this by
- Moving the automobile while keeping the background fixed-(Geometric Transformation)
- We can keep the car fixed while moving the background scenery- (Coordinate Transformation)
Types of Transformations:
- Translation
- Scaling
- Rotating
- Reflection
- Shearing
Translation
It is the straight line movement of an object from one position to another is called Translation. Here the object is positioned from one coordinate location to another.
Translation of point:
To translate a point from coordinate position (x, y) to another (x1 y1), we add algebraically the translation distances Tx and Ty to original coordinate.
x1=x+Tx
y1=y+Ty
The translation pair (Tx,Ty) is called as shift vector.
Translation is a movement of objects without deformation. Every position or point is translated by the same amount. When the straight line is translated, then it will be drawn using endpoints.
For translating polygon, each vertex of the polygon is converted to a new position. Similarly, curved objects are translated. To change the position of the circle or ellipse its center coordinates are transformed, then the object is drawn using new coordinates.
Let P is a point with coordinates (x, y). It will be translated as (x1 y1).


Matrix for Translation:

Scaling:
It is used to alter or change the size of objects. The change is done using scaling factors. There are two scaling factors, i.e. Sx in x direction Sy in y-direction. If the original position is x and y. Scaling factors are Sx and Sy then the value of coordinates after scaling will be x1 and y1.
If the picture to be enlarged to twice its original size then Sx = Sy =2. If Sxand Sy are not equal then scaling will occur but it will elongate or distort the picture.
If scaling factors are less than one, then the size of the object will be reduced. If scaling factors are higher than one, then the size of the object will be enlarged.
If Sxand Syare equal it is also called as Uniform Scaling. If not equal then called as Differential Scaling. If scaling factors with values less than one will move the object closer to coordinate origin, while a value higher than one will move coordinate position farther from origin.
Enlargement: If T1=
,If (x1 y1)is original position and T1is translation vector then (x2 y2) are coordinated after scaling

The image will be enlarged two times

Reduction: If T1=
. If (x1 y1) is original position and T1 is translation vector, then (x2 y2) are coordinates after scaling




Matrix for Scaling:

Example: Prove that 2D Scaling transformations are commutative i.e, S1 S2=S2 S1.
Solution: S1 and S2 are scaling matrices

Rotation:
It is a process of changing the angle of the object. Rotation can be clockwise or anticlockwise. For rotation, we have to specify the angle of rotation and rotation point. Rotation point is also called a pivot point. It is print about which object is rotated.
Types of Rotation:
- Anticlockwise
- Counterclockwise
The positive value of the pivot point (rotation angle) rotates an object in a counter-clockwise (anti-clockwise) direction. The negative value of the pivot point (rotation angle) rotates an object in a clockwise direction. When the object is rotated, then every point of the object is rotated by the same angle.
Straight Line: Straight Line is rotated by the endpoints with the same angle and redrawing the line between new endpoints.
Polygon: Polygon is rotated by shifting every vertex using the same rotational angle.
Curved Lines: Curved Lines are rotated by repositioning of all points and drawing of the curve at new positions.
Circle: It can be obtained by center position by the specified angle.
Ellipse: Its rotation can be obtained by rotating major and minor axis of an ellipse by the desired angle.


Matrix for rotation is a clockwise direction.

Matrix for rotation is an anticlockwise direction.

Matrix for homogeneous co-ordinate rotation (clockwise)

Matrix for homogeneous co-ordinate rotation (anticlockwise)

Rotation about an arbitrary point:
If we want to rotate an object or point about an arbitrary point, first of all, we translate the point about which we want to rotate to the origin. Then rotate point or object about the origin, and at the end, we again translate it to the original place. We get rotation about an arbitrary point.
Example: The point (x, y) is to be rotated
The (xc yc) is a point about which counterclockwise rotation is done
Step1: Translate point (xc yc) to origin

Step2: Rotation of (x, y) about the origin

Step3: Translation of center of rotation back to its original position


Example1: Prove that 2D rotations about the origin are commutative i.e. R1 R2=R2 R1.
Solution: R1 and R2are rotation matrices

Reflection:
It is a transformation which produces a mirror image of an object. The mirror image can be either about x-axis or y-axis. The object is rotated by180°.
Types of Reflection:
- Reflection about the x-axis
- Reflection about the y-axis
- Reflection about an axis perpendicular to xy plane and passing through the origin
- Reflection about line y=x
1. Reflection about x-axis: The object can be reflected about x-axis with the help of the following matrix

In this transformation value of x will remain same whereas the value of y will become negative. Following figures shows the reflection of the object axis. The object will lie another side of the x-axis.

2. Reflection about y-axis: The object can be reflected about y-axis with the help of following transformation matrix
Here the values of x will be reversed, whereas the value of y will remain the same. The object will lie another side of the y-axis.
The following figure shows the reflection about the y-axis

3. Reflection about an axis perpendicular to xy plane and passing through origin:
In the matrix of this transformation is given below


In this value of x and y both will be reversed. This is also called as half revolution about the origin.
4. Reflection about line y=x: The object may be reflected about line y = x with the help of following transformation matrix


First of all, the object is rotated at 45°. The direction of rotation is clockwise. After it reflection is done concerning x-axis. The last step is the rotation of y=x back to its original position that is counterclockwise at 45°.
Example: Find reflected position of triangle i.e., to the x-axis.
Solution:


The a point coordinates after reflection

The b point coordinates after reflection

The coordinate of point c after reflection

a (3, 4) becomes a1 (3, -4)
b (6, 4) becomes b1 (6, -4)
c (4, 8) becomes c1 (4, -8)
Shearing:
It is transformation which changes the shape of object. The sliding of layers of object occur. The shear can be in one direction or in two directions.
Shearing in the X-direction:
In this horizontal shearing sliding of layers occur. The homogeneous matrix for shearing in the x-direction is shown below:


Shearing in the Y-direction: Here shearing is done by sliding along vertical or y-axis.

Shearing in X-Y directions:
Here layers will be sided in both x as well as y direction. The sliding will be in horizontal as well as vertical direction. The shape of the object will be distorted. The matrix of shear in both directions is given by:

Composite Transformation:
A number of transformations or sequence of transformations can be combined into single one called as composition. The resulting matrix is called as composite matrix. The process of combining is called as concatenation. Suppose we want to perform rotation about an arbitrary point, then we can perform it by the sequence of three transformations
- Translation
- Rotation
- Reverse Translation
The ordering sequence of these numbers of transformations must not be changed. If a matrix is represented in column form, then the composite transformation is performed by multiplying matrix in order from right to left side. The output obtained from the previous matrix is multiplied with the new coming matrix.
Example showing composite transformations:
The enlargement is with respect to center. For this following sequence of transformations will be performed and all will be combined to a single one. Composition of two Scaling: The composition of two scaling is multiplicative. Let S11 and S12are matrix to be multiplied.

Step1: The object is kept at its position as in fig (a)
Step2: The object is translated so that its center coincides with the origin as in fig (b)
Step3: Scaling of an object by keeping the object at origin is done in fig (c)
Step4: Again translation is done. This second translation is called a reverse translation. It will position the object at the origin location.
Above transformation can be represented as TV.STV-1

Note: Two types of rotations are used for representing matrices one is column method. Another is the row method.

Advantage of composition or concatenation of matrix:
- It transformations become compact.
- The number of operations will be reduced.
- Rules used for defining transformation in form of equations are complex as compared to matrix.
Composition of two translations:
Let t1 t2 t3 t4are translation vectors. They are two translations P1 and P2. The matrix of P1 and P2 given below. The P1 and P2are represented using Homogeneous matrices and P will be the final transformation matrix obtained after multiplication.

Above resultant matrix show that two successive translations are additive.
Composition of two Rotations: Two Rotations are also additive
Composition of two Scaling: The composition of two scaling is multiplicative. Let S11 and S12are matrix to be multiplied.
