3D Geometric Transformation: Siddhartha B S, Asst. Professor, Adichunchanagiri University

You might also like

You are on page 1of 20

Module 3

3D Geometric Transformation

Siddhartha B S, Asst. Professor, Adichunchanagiri University 1


3D Translation
 Moving a point from one location to another. (from one coordinate position to
another coordinate position).
 Position P(x,y,z) in 3D space is translated to a location P’(x’,y’,z’)
 By adding translation distance tx, ty, tz to x,y,z respectively.
x’ = x + tx y ’= y + ty z’ = z + tz
 3D translation operation in matrix form

Siddhartha B S, Asst. Professor, Adichunchanagiri University 2


 Moving a coordinate position with translation vector T = (tx, ty, tz)

 Shifting the position of a 3D object using translation vector T

Siddhartha B S, Asst. Professor, Adichunchanagiri University 3


3D Scaling
 To alter the size of an object, we apply the scaling transformation.
 Wherever we perfom scaling we need scaling factors Sx, Sy, Sz
 The matrix expression for the three-dimensional scaling transformation of a position P
= (x, y, z) is given by

 The three-dimensional scaling transformation for a point position can be represented as


P’ = S * P
where scaling parameters Sx, Sy, and Sz are assigned any positive values.
 Explicit expressions for the scaling transformation relative to the origin are
x’ = x * Sx y’ = y * Sy z’ = z * Sz
Siddhartha B S, Asst. Professor, Adichunchanagiri University 4
 If we are perfoming scaling w.r.t any point lets consider (xf, yf,zf)
1. Translate (xf, yf,zf) to origin
2. Perform scaling operation S
3. Translate the fixed point back to its original position. [T-1 = (-xf, -yf, -zf)]

Siddhartha B S, Asst. Professor, Adichunchanagiri University 5


 Matix Form

1 0 0 -xf Sx 0 0 0 1 0 0 xf
0 1 0 -yf 0 Sy 0 0 0 1 0 yf
0 0 1 -zf 0 0 Sz 0 0 0 1 zf
0 0 0 1 0 0 0 1 0 0 0 1

Siddhartha B S, Asst. Professor, Adichunchanagiri University 6


3D Rotation

 In 2D, we will consider two axis i.e., x & y considering any one of the axis as
reference point we preform rotation.

 In 3D, we need to have one reference axis also.

 Rotation about

 Any axis as reference

 Any line which is parallel to any axis

 Any line which is not parallel to any axis

Siddhartha B S, Asst. Professor, Adichunchanagiri University 7


Case 1: 3D Coordinate-Axis Rotations
 Rotation about Z axis
 x’ = x cosθ – y sinθ
 y’ = x sinθ + y cos θ
 z’ = z
 Rotation about X axis x’ x 0 0 0 0 0
 x’ = x y’ y 0 0 cos θ -sin θ 0
z’ z 0 0 sin θ cos θ 0
 y’ = y cosθ - z sinθ 0 0 0 0 1
1 1
 z’ = y sinθ + z cosθ
 Rotation about Y axis
 x’ = z sinθ + x cosθ x’ x cos θ 0 sin θ 0 0
y’ y 0 0 0 0 0
 y’ = y z’ z -sin θ 0 cos θ 1 0
 z’ = z cosθ - x sinθ 1 1 0 0 0 0 1
Siddhartha B S, Asst. Professor, Adichunchanagiri University 8
Case 2 : Any line which is parallel to any axis
 When an object is to be rotated about an axis that is parallel to one of the coordinate
axis.
2)

1) 3)

Siddhartha B S, Asst. Professor, Adichunchanagiri University


Case 3 : Any line which is not parallel to any
axis

Siddhartha B S, Asst. Professor, Adichunchanagiri University 10


Siddhartha B S, Asst. Professor, Adichunchanagiri University 11
3D Reflection
 It is mirror image of an object, depending upon the axis we get the mirror image.

 A reflection in a three-dimensional space can be performed relative to a selected reflection


axis or with respect to a reflection plane.
 An example of a reflection that converts coordinate specifications froma right handed system
to a left-handed system is shown below

 The matrix representation for this reflection relative to the xy plane is

12
 Similarly, reflection can be performed on yz plane and zx plane.
Siddhartha B S, Asst. Professor, Adichunchanagiri University
3D Shears

 These transformations can be used to modify object shapes.


 For three-dimensional we can also generate shears relative to the z axis.
 A general z-axis shearing transformation relative to a selected reference
position is produced with the following matrix:

Siddhartha B S, Asst. Professor, Adichunchanagiri University 13


Polygon Fill Area Clipping
 To clip a polygon fill area, we cannot apply a line-clipping method to the individual polygon edges.
 Polygon clipping can be done by processing all the polygon vertices against each boundary of clipping
window.
 We can clip a polygon fill area by determining the new shape for the polygon as each clipping window edge
is processed, as demonstrated.

14

Siddhartha B S, Asst. Professor, Adichunchanagiri University


 To implement convex-polygon clipping is to create a new vertex list at each clipping boundary, and then
pass this new vertex list to the next boundary clipper.
 The output of the final clipping stage is the vertex list for the clipped polygon

15

Siddhartha B S, Asst. Professor, Adichunchanagiri University


Sutherland - Hodgman Polygon Clipping

 It is developed by Sutherland and Hodgman.

 An efficient method for clipping a polygon fill area is to send the polygon vertices through each clipping
stage so that a single clipped vertex can be immediately passed to the next stage.

 The general strategy in this algorithm is to send the pair of endpoints for each successive polygon line
segment through the series of clippers (left, right, bottom, and top)

Siddhartha B S, Asst. Professor, Adichunchanagiri University 16


 There are four possible cases that need to be considered when processing a polygon edge against one of the
clipping boundaries.

17

Siddhartha B S, Asst. Professor, Adichunchanagiri University


18

Siddhartha B S, Asst. Professor, Adichunchanagiri University


19

Siddhartha B S, Asst. Professor, Adichunchanagiri University


Self Learning Concepts
 OpenGL Geometric Transformation Functions

Siddhartha B S, Asst. Professor, Adichunchanagiri University 20

You might also like