3D computer Graphic PPT.pptx in computer graphics

463 views 18 slides Jan 25, 2024
Slide 1
Slide 1 of 18
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18

About This Presentation

Easy presentation for college students on 3-D Computer Graphics


Slide Content

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.

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. 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

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. Matrix representation of point translation. Point shown in fig is (x, y, z). It become (x 1 ,y 1 ,z 1 ) after translation. T x  T y   T z  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 x becomes x 1 =8 y becomes y 1 =9 z becomes z 1 =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 S x   S y  and S z . S x =Scaling factor in x- direction S y =Scaling factor in y-direction S z =Scaling factor in z-direction Matrix for Scaling-

Example:- Given a 3D object with coordinate points A(0, 3, 3), B(3, 3, 6). Apply the scaling parameter 2 towards X axis, 3 towards Y axis and 3 towards Z axis and obtain the new coordinates of the object. Solution :- Given- Old coordinates of the object  = A (0, 3, 3), B(3, 3, 6). Scaling factor along X axis = 2 Scaling factor along Y axis = 3 Scaling factor along Z axis = 3 For Coordinates A(0, 3, 3) Let the new coordinates of A after scaling = ( X new , Y new , Z new ). X new  = X old  x S x  = 0  x 2 = 0 Y new  = Y old  x S y  = 3 x 3 = 9 Z new  = Z old  x S z  = 3 x 3 = 9 Thus, New coordinates of corner A after scaling = (0, 9, 9).

For Coordinates B(3, 3, 6) Let the new coordinates of B after scaling = ( X new , Y new , Z new ). X new  = X old  x S x  = 3  x 2 = 6 Y new  = Y old  x S y  = 3 x 3 = 9 Z new  = Z old  x S z  = 6 x 3 = 18 Thus, New coordinates of corner B after scaling = (6, 9, 18).

Rotation It is moving of an object about an angle. Movement can be anticlockwise or clockwise. 3D rotation is complex as compared to the 2D rotation. For 2D we describe the angle of rotation, but for a 3D angle of rotation and axis of rotation are required. The axis can be either x or y or z.

Matrix for representing three-dimensional rotations about the Z axis Matrix for representing three-dimensional rotations about the X axis Matrix for representing three-dimensional rotations about the Y axis

Example:- Given a homogeneous point (1, 2, 3). Apply rotation 90 degree towards X, Y and Z axis and find out the new coordinate points. Solution :- Old coordinates = ( X old , Y old , Z old ) = (1, 2, 3) Rotation angle = θ = 90º For X-Axis Rotation- X new  = X old  = 1 Y new  = Y old  x cos θ – Z old  x sin θ = 2 x cos90° – 3 x sin90° = 2 x 0 – 3 x 1 = -3 Z new  = Y old  x sin θ + Z old  x cos θ = 2 x sin90° + 3 x cos90° = 2 x 1 + 3 x 0 = 2 Thus, New coordinates after rotation = (1, -3, 2).0 For Y-Axis Rotation-   X new  = Z old  x sin θ + X old  x cos θ = 3 x sin90° + 1 x cos90° = 3 x 1 + 1 x 0 = 3 Y new  =  Y old  = 2 Z new  = Y old  x cos θ – X old  x sin θ = 2 x cos90° – 1 x sin90° = 2 x 0 – 1 x 1 = -1 Thus, New coordinates after rotation = (3, 2, -1). For Z-Axis Rotation- X new  = X old  x cos θ – Y old  x sin θ = 1 x cos90° – 2 x sin90° = 1 x 0 – 2 x 1 = -2 Y new  = X old  x sin θ + Y old  x cos θ = 1 x sin90° + 2 x cos90° = 1 x 1 + 2 x 0 = 1 Z new  = Z old  = 3  Thus, New coordinates after rotation = (-2, 1, 3).

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

Matrix For XYCoordinates :- Reflection relative to YZ plane Reflection relative to XZ plane Example:- Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4, 2), C(5, 6, 3). Apply the reflection on the XY plane and find out the new coordinates of the object. Solution-  Given:-Old corner coordinates of the triangle = A (3, 4, 1), B(6, 4, 2), C(5, 6, 3) Reflection has to be taken on the XY plane

For Coordinates A(3, 4, 1) Let the new coordintes of corner A after reflection = ( X new , Y new , Z new ). X new  = X old  = 3 Y new  = Y old  = 4 Z new  = - Z old  = -1  Thus, New coordinates of corner A after reflection = (3, 4, -1) For Coordinates B(6, 4, 2)   Let the new coordinate of corner B after reflection = ( X new , Y new , Z new ). X new  = X old  = 6 Y new  = Y old  = 4 Z new  = - Z old  = -2  Thus, New coordinates of corner B after reflection = (6, 4, -2).  For Coordinates C(5, 6, 3)   Let the new coordinates of corner C after reflection = ( X new , Y new , Z new ). X new  = X old  = 5 Y new  = Y old  = 6 Z new  = - Z old  = -3  Thus, New coordinates of corner C after reflection = (5, 6, -3). Thus, New coordinates of the triangle after reflection = A (3, 4, -1), B(6, 4, -2), C(5, 6, -3).

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 Shearing in X Axis-   Shearing in X axis is achieved by using the following shearing equations- X new  = X old Y new  = Y old  + Sh y  x X old Z new  = Z old  + Sh z  x X old Shearing in Y Axis-   Shearing in Y axis is achieved by using the following shearing equations- X new  = X old  + Sh x  x Y old Y new  = Y old Z new  = Z old  + Sh z  x Y old

Shearing in Z Axis- Shearing in Z axis is achieved by using the following shearing equations- X new  = X old  + Sh x  x Z old Y new  = Y old  + Sh y  x Z old Z new  = Z old Example:- Given a 3D triangle with points (0, 0, 0), (1, 1, 2) and (1, 1, 3). Apply shear parameter 2 on X axis, 2 on Y axis and 3 on Z axis and find out the new coordinates of the object Solution-   Old corner coordinates of the triangle = A (0, 0, 0), B(1, 1, 2), C(1, 1, 3) Shearing parameter towards X direction ( Sh x ) = 2 Shearing parameter towards Y direction (Sh y ) = 2 Shearing parameter towards Y direction ( Sh z ) = 3 Shearing in X Axis-

Coordinates A(0, 0, 0)   Let the new coordinates of corner A after shearing = ( X new , Y new , Z new ).  Applying the shearing equations, we have- X new  = X old  = 0 Y new  = Y old  + Sh y  x X old  = 0 + 2 x 0 = 0 Z new  = Z old  + Sh z  x X old  = 0 + 3 x 0 = 0 Thus, New coordinates of corner A after shearing = (0, 0, 0). For Coordinates B(1, 1, 2) Let the new coordinates of corner B after shearing = ( X new , Y new , Z new ). Applying the shearing equations, we have- X new  = X old  = 1 Y new  = Y old  + Sh y  x X old   = 1 + 2 x 1 = 3 Z new  = Z old  + Sh z  x X old  = 2 + 3 x 1 = 5 Thus, New coordinates of corner B after shearing = (1, 3, 5). For Coordinates C(1, 1, 3)

Let the new coordinates of corner C after shearing = ( X new , Y new , Z new ).  Applying the shearing equations, we have- X new  = X old  = 1 Y new  = Y old  + Sh y  x X old  = 1 + 2 x 1 = 3 Z new  = Z old  + Sh z  x X old  = 3 + 3 x 1 = 6 Thus, New coordinates of corner C after shearing = (1, 3, 6). Thus, New coordinates of the triangle after shearing in X axis = A (0, 0, 0), B(1, 3, 5), C(1, 3, 6).