You are on page 1of 56

CSE202 –

Computer Graphics Using


OpenGL
Unit II
Geometric Transformation

27-03-2021
2D Geometric Transformation
• Basic 2D Transformations
• Homogeneous Coordinates
• Composite Transformations
• Other 2D Transformations

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et al., 2


Basic 2D Transformations
• Operations that are applied to the geometric description of an object
to change its position, orientation, or size are called geometric
transformations.
• Two-Dimensional Translation
• Two-Dimensional Rotation
• Two-Dimensional Scaling

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 3
Two-Dimensional Translation
• A translation on a single coordinate point by adding offsets to its
coordinates so as to generate a new coordinate position
• Moving the original point position along a straight-line path to its new
location
• Every point on the object is translated by the same amount

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 4
Two-Dimensional Translation (Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 5
Two-Dimensional Translation (Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 6
Two-Dimensional Rotation
• All points of the object are then transformed to new positions by
rotating the points through the specified angle about the rotation
axis.
• Origin
• Pivot point

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 7
Rotation (Contd.)
• Origin

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 8
Rotation (Contd.)
• Arbitrary Pivot position

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 9
Two-Dimensional Scaling
• A simple 2D scaling operation is performed by multiplying object
positions (x, y) by scaling factors sx and sy to produce the transformed
coordinates.

• Uniform /differential scaling


27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 10
Scaling (Contd.)
• Fixed point scaling

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 11
27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 12
27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 13
27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 14
Homogeneous Coordinates
• Many graphics applications involve sequences of geometric
transformations
• Multiplicative and translational terms for 2D geometric
transformation can be combined into a single matrix as 3×3 matrices
• All transformation equations can be expressed as matrix
multiplications

• Where the homogeneous parameter “h” is a nonzero value such that

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 15
Homogeneous Coordinates(Contd)
• Therefore, a general 2D homogeneous coordinate representation
could also be written as

• Each two-dimensional position is then represented with


homogeneous coordinates

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 16
2D Homogeneous Matrix

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 17
27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 18
27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 19
27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 20
27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 21
Composite 2D Translations
• Two successive translations are additive

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 22
Composite 2D Rotations
• Two successive rotations are additive

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 23
Composite 2D Rotations (Contd.)
• Two successive rotations are additive

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 24
Composite 2D Scalings
• Two successive scaling operations are multiplicative

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 25
General 2D Pivot-Point Rotation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 26
General 2D Pivot-Point Rotation(Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 27
General 2D Fixed-Point Scaling

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 28
General 2D Fixed-Point Scaling(Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 29
General 2D Scaling Directions
• To accomplish the scaling without changing the orientation of the
object
• perform a rotation
• scaling transformation
• opposite rotation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 30
Matrix Concatenation Properties
• Multiplication of matrices is associative

• It may not be commutative

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 31
General 2D Composite Transformations

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 32
2D Rigid-Body Transformation
• If a transformation matrix includes only translation and rotation
parameters, it is a rigid-body transformation matrix

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 33
Other 2D Transformations
• Reflection
• A transformation that produces a mirror image of
an object is called a reflection
• Reflection about the line y = 0 (the x axis)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 34
Other 2D Transformations (Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 35
Other 2D Transformations (Contd.)
• Shear
• A transformation that distorts the shape of an object
• such that the transformed shape appears as if the object were composed of
internal layers

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 36
Other 2D Transformations (Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 37
Other 2D Transformations (Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 38
Other 2D Transformations (Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 39
Basic 3D Transformations
• 2D methods by including considerations for the z coordinate
• homogeneous coordinates is represented as 4 x 4 matrix

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 40
Basic 3D Translation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 41
Basic 3D Rotation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 42
Z – Axis Rotation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 43
X & Y – Axis Rotation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 44
General Three-Dimensional Rotations
• A rotation matrix for any axis that does not coincide with a coordinate
axis can be set up as a composite transformation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 45
General 3D Rotations(Contd.)
• When an object is to be rotated about an axis that is not parallel to
one of the coordinate axes, we must perform some additional
transformations

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 46
General 3D Rotations(Contd.)

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 47
Three-Dimensional Scaling

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 48
3D – Fixed Point Scaling

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 49
Problem

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 50
Composite 3D Transformations
• We can implement a transformation sequence by concatenating the
individual matrices from right to left or from left to right, depending
on the order in which the matrix representations are specified
• The rightmost term in a matrix product is always the first
transformation to be applied to an object and the leftmost term is
always the last transformation

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 51
Other 3D Transformations
• Three-Dimensional Reflections
• Performed relative to a selected reflection axis or with respect to a reflection
plane
• The matrix representation for this reflection relative to the “xy” plane is

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 52
Three-Dimensional Shears
• A general z-axis shearing transformation relative to a selected
reference position is produced with the following matrix:

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 53
OpenGL Geometric Transformation Example

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 54
OpenGL Geometric Transformation Functions

27-03-2021 Ref: Computer Graphics with OpenGL by Donald D. Hearn et. al. 55
References
• Donald D. Hearn, M. Pauline Baker and Warren Carithers, “Computer
Graphics with OpenGL”, Pearson Education, Fourth Edition, 2011.

27-03-2021 56

You might also like