SlideShare a Scribd company logo
1 of 122
Part - #2
Geometric
Transformation (2D & 3D)
March, 2019
10/5/2022 2
Intro & General Information
Geometric Transformations
Construction
(translate, rotate, scale, mirror)
Viewing
(projections, zooming)
Animation
(processes, vibration)
Coordinate Systems
 In order to specify the geometry of a given solid, it is necessary to
use a variety of coordinate systems. Its Major classifications are:
 World Coordinate System: Also known as the "universe" or
sometimes "model" coordinate system. This is the base reference
system for the overall model, ( generally in 3D ), to which all other
model coordinates relate
 User Coordinate System: Also known as “working” coordinate
system. When it is difficult to define certain geometries using
WCS, In such cases user coordinate system can be defined relative
to the WCS.
 Display Coordinates: This refers to the actual coordinates to be
used for displaying the image on the screen.
10/5/2022 4
General Information
Transformation of a point is basic in GT. It can be formulated as follows:
Given a point P that belongs to a geometric model find the corresponding
point P* in the new position such that
P* = f(P, transformation parameters)
• The transformation parameters should provide ONE-TO-ONE-
MAPPING.
• Multiple transformations can be combined to yield a single
transformation which should have the same effect as the sequential
application of original ones. CONCATENATION /kənˌkatnˈāSH(ə)n/
Equation of P* for graphics hardware should be in matrix notation:
P* = [T]P,
where [T] is the transformation matrix.
Geometric Transformations
 Sometimes also called modeling
transformations
 Geometric transformations: Changing an object’s
position (translation), orientation (rotation) or size
(scaling)
 Modeling transformations: Constructing a scene
or hierarchical description of a complex object
 Others transformations: reflection and
shearing operations
5
1. Geometric Transformations
 What is transformation?
> It is the backbone of computer graphics, enabling us to
manipulate the shape, size, and location of the object.
> Changing something to something else via rules.
 Why are they important to graphics?
> It can be used to effect the following changes in a geometric
object:
1. Change the location
2. Change the shape
3. Change the size
4. Rotate
2. Types of Transformations
i. Geometric/Object Transformation
> This transformation alters the coordinate values of the object. Basic
operations are scaling, translation, rotation and combination of one
or more of these basic transformations.
> Object transformation = Move (transform) an object in the 2D/3D space.
ii. Visual/ Coordinate System Transformation
> In this transformation there is no change in either the geometry or the
coordinates of the object. A copy of the object is placed at the desired sight,
without changing the coordinate values of the object.
> Coordinate system transformation = Move (transform) the coordinate
system. View the objects from the new coordinate system.
8
3. Types of Geometric Transformations
 Translation
 Rotation
 Scaling
 Reflection/Mirroring.
10/5/2022 9
Translation
Translation is a rigid-body transformation (Euclidean) when
each entity of the model remains parallel, or each point
moves an equal distance in a given direction:
P* = P + d (for both 2D and 3D). In a scalar form (for 3D):
x* = x + xd
y* = y + yd
z* = z + zd
C (11,7)
A (8,5)
B (10,8)
A*
C*
B*
y
x
O
Question: Find the coordinates of vertices A*, B*,
and C* of the translated triangle.
The distance vector of translation: D = [-7 -4]T.
Verify that the lengths of the edges are unchanged.
i. Translation - 2D
Moving an object is called a translation.
We translate a point by adding to the x and y coordinates,
respectively, the amount the point should be shifted in the x and y
directions.
We translate an object by translating each vertex in the object.
Basic 2D Geometric
Transformations
 2D Translation
 x’ = x + tx , y’ = y + ty
 P’=P+T
 Translation moves the object without deformation
(rigid-body transformation)
P
P’
T





















y
x
t
t
T
y
x
P
y
x
P ,
'
'
'
,
11
Basic 2D Geometric
Transformations (cont.)
 2D Translation
 To move a line segment, apply the transformation
equation to each of the two line endpoints and
redraw the line between new endpoints
 To move a polygon, apply the transformation
equation to coordinates of each vertex and
regenerate the polygon using the new set of vertex
coordinates
12
Scaling is used to change the size of an entity or a model.
P* = [S]P
sx 0 0
For general case [S] = 0 sy 0 ,
0 0 sz
If 0 < s < 1 - compression
If s > 1 - stretching
sx = sy = sz - uniform scaling, otherwise - non-uniform
10/5/2022 13
Scaling
where sx, sy, and sz are the scaling
factors in the X, Y, and Z directions
respectively.
Question: The larger circle is the scaled copy
of the smaller one. Can you say that we have a
uniform scaling? Why? Define y* and R*.
O(4,2)
O*(10,y*)
O
x
y
R 1
R*
ii. Scaling
> Changing the size of an object is called a scale. We scale an
object by scaling the x and y coordinates of each vertex in the
object.
 2D Rotation
 Rotation axis
 Rotation angle
 rotation point or pivot point (xr,yr)
yr
xr
θ
Basic 2D Geometric
Transformations (cont.)
15
2D Geometric Transformations
 2D Rotation
 If θ is positive  counterclockwise rotation
 If θ is negative  clockwise rotation
 Remember:
 cos(a + b) = cos a cos b - sin a sin b
 cos(a - b) = cos a sin b + sin a cos b
Basic 2D Geometric
Transformations (cont.)
16
2D Geometric Transformations
10/5/2022 17
Rotation
Rotation is a non-commutative transformation (depends on sequence).
 
 
 
 

































 

















































































































cos
0
sin
0
1
0
sin
0
cos
cos
sin
0
sin
cos
0
0
0
1
1
0
0
0
cos
sin
0
sin
cos
cos
sin
sin
cos
cos
sin
sin
cos
sin
sin
cos
cos
)
sin(
)
cos(
P
sin
cos
P
P
P
*
*
*
*
*
y
x
z
R
R
R
z
y
x
y
x
z
r
r
r
r
z
r
r
z
y
x
z
r
r
z
y
x
R


P*
P
x
y*
x*
y
X
Y
Z
Question: Let the length of a major and minor
axes of an ellipse with the center on the origin
of the CS be 2a and 2b respectively, and  - the
angle between the major axis and the x-axis.
Then, derive the expression of an ellipse in the
(O,x,y) system.
iii. Rotation about the origin
ø Consider rotation about the origin by Θ degrees
ø Radius stays the same, angle increases by Θ.
 2D Rotation
 At first, suppose the pivot point is at the origin
 x’=r cos(θ+Φ) = r cos θ cos Φ - r sin θ sin Φ
y’=r sin(θ+Φ) = r cos θ sin Φ + r sin θ cos Φ
 x = r cos Φ, y = r sin Φ
 x’=x cos θ - y sin θ
y’=x sin θ + y cos θ
Φ
(x,y)
r
r θ
(x’,y’)
Basic 2D Geometric
Transformations (cont.)
19
2D Geometric Transformations
Basic 2D Geometric
Transformations
 2D Rotation
 P’=R·P












cos
sin
sin
cos
R
Φ
(x,y)
r
r θ
(x’,y’)
20
2D Geometric Transformations
3. Transformations as Matrices
Cont’d…
Example:
• Translate the rectangle (2, 2), (2, 8), (10, 8), (10, 2)
2 units along x-axis and 3 units along y-axis.
Cont’d…
 2D Scaling
 Scaling is used to alter the size of an object
 Simple 2D scaling is performed by multiplying
object positions (x, y) by scaling factors sx and sy
x’ = x · sx
y’ = y · sx
or P’ = S·P




















y
x
s
s
y
x
y
x
0
0
'
'
Basic 2D Geometric
Transformations (cont.)
24
 2D Scaling
 Any positive value can be used as scaling factor
 Values less than 1 reduce the size of the object
 Values greater than 1 enlarge the object
 If scaling factor is 1 then the object stays unchanged
 If sx = sy , we call it uniform scaling
 If scaling factor <1, then the object moves closer to the
origin and If scaling factor >1, then the object moves
farther from the origin
x’ x
Basic 2D Geometric
Transformations (cont.)
25
 2D Scaling
 Why does scaling also reposition object?
 Answer: See the matrix (multiplication)
 Still no clue?

𝑥′
𝑦′
=
𝑠𝑥 0
0 𝑠𝑦
∗
𝑥
𝑦 =
𝑥 ∗ 𝑠𝑥 + 𝑦 ∗ 0
𝑥 ∗ 0 + 𝑦 ∗ 𝑠𝑦
Basic 2D Geometric
Transformations (cont.)
26
 2D Scaling
 We can control the location of the scaled object by
choosing a position called the fixed point (xf,yf)
x’ – xf = (x – xf) sx y’ – yf = (y – yf) sy
x’=x · sx + xf (1 – sx)
y’=y · sy + yf (1 – sy)
 Polygons are scaled by applying the above formula
to each vertex, then regenerating the polygon using
the transformed vertices
Basic 2D Geometric
Transformations (cont.)
27
Example:
 If the triangle A(1, 1), B(2, 1), C(1, 3) is scaled by a
factor 2, find the new coordinates of the triangle.
Cont’d…
Cont’d…
Example:
• Rotate the rectangle (0, 0), (2, 0), (2, 2), (0, 2) by 30o
ccw about its centroid and find the new coordinates
of the rectangle.
Summary
4. Homogeneous Coordinates
> In order to represent a translation as a matrix multiplication
operation we use 3 x 3 matrices and pad the points to become 3 x 1
matrices.
> This coordinate system (using three values to represent a 2D point) is
called homogeneous coordinates.
> Let the added extra coordinate be W, to a point: P (x, y, W).
> Two sets of homogeneous coordinates represent the same point if
they are a multiple of each other.
> If W ≠ 0 , divide by it to get Cartesian coordinates of point: (x/W,
y/W, 1).
> If W = 0, point is said to be at infinity.
Cont’d…
Transformation matrices for 2D translation are now 3x3.
5. Concatenation of transformation
Cont’d…
Properties of Translations
Homogeneous form of scale
Concatenation of scales
10/5/2022 39
Homogeneous Transformation
When we scale then rotate, the transformed image is given by:
P* = ([R][S])P
where [S], [R], [R] [S] are 3x3 transformation matrices. This is not the case
for a translation (P* = P + d). The goal is to find a [D] such that
P + d = [D]P
in order to perform valid matrix multiplication.
This is found by using a homogeneous coordinates.
Homogeneous Transformation maps n-dimensional space into (n+1)- dim.
3D representation of the point vector - P = [x, y, z]T
Homogeneous rep. of the same vector - P = [xw, yw, zw, w]T where w = 1
Matrix Representations and
Homogeneous Coordinates
 Many graphics applications involve
sequences of geometric transformations
 Animations
 Design and picture construction applications
 We will now consider matrix representations
of these operations
 Sequences of transformations can be efficiently
processed using matrices
40
2D Geometric Transformations
Matrix Representations and
Homogeneous Coordinates (cont.)
 P’ = M1 · P + M2
 P and P’ are column vectors
 M1 is a 2 by 2 array containing multiplicative
factors
 M2 is a 2 element column matrix containing
translational terms
 For translation M1 is the identity matrix
 For rotation or scaling, M2 contains the
translational terms associated with the pivot point
or scaling fixed point
41
2D Geometric Transformations
 To produce a sequence of operations, such
as scaling followed by rotation then
translation, we could calculate the
transformed coordinates one step at a time
 A more efficient approach is to combine
transformations, without calculating
intermediate coordinate values
Matrix Representations and
Homogeneous Coordinates (cont.)
42
2D Geometric Transformations
 Multiplicative and translational terms for a 2D
geometric transformation can be combined
into a single matrix if we expand the
representations to 3 by 3 matrices
 We can use the third column for translation terms,
and all transformation equations can be
expressed as matrix multiplications
Matrix Representations and
Homogeneous Coordinates (cont.)
43
2D Geometric Transformations
 Expand each 2D coordinate (x,y) to three
element representation (xh,yh,h) called
homogeneous coordinates
 h is the homogeneous parameter such that
x = xh/h, y = yh/h,
  infinite homogeneous representations for a
point
 A convenient choice is to choose h = 1
Matrix Representations and
Homogeneous Coordinates (cont.)
44
2D Geometric Transformations
10/5/2022 45
Homogeneous Transformation
The transformation matrices in new (homogeneous) representation:
   
   























































1
0
0
0
0
0
0
R
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
1
33
32
31
23
22
21
13
12
11
r
r
r
r
r
r
r
r
r
M
s
s
s
S
z
y
x
D
z
y
x
d
d
d
 2D Translation Matrix
or, P’ = T(tx,ty)·P
































1
1
0
0
1
0
0
1
1
'
'
y
x
t
t
y
x
y
x
Matrix Representations and
Homogeneous Coordinates (cont.)
46
2D Geometric Transformations
 2D Rotation Matrix
or, P’ = R(θ)·P





































1
1
0
0
0
cos
sin
0
sin
cos
1
'
'
y
x
y
x
Matrix Representations and
Homogeneous Coordinates (cont.)
47
2D Geometric Transformations
 2D Scaling Matrix
or, P’ = S(sx,sy)·P
































1
1
0
0
0
0
0
0
1
'
'
y
x
s
s
y
x
y
x
Matrix Representations and
Homogeneous Coordinates (cont.)
48
2D Geometric Transformations
Inverse Transformations
 2D Inverse Translation Matrix
 By the way:














1
0
0
1
0
0
1
1
y
x
t
t
T
I
T
T 

*
1
49
2D Geometric Transformations
Inverse Transformations (cont.)
 2D Inverse Rotation Matrix
 And also:

















1
0
0
0
cos
sin
0
sin
cos
1
R
I
R
R 

*
1
50
2D Geometric Transformations
Inverse Transformations (cont.)
 2D Inverse Rotation Matrix:
 If θ is negative  clockwise
 In
 Only sine function is affected
 Therefore we can say
 Is that true?
 Proof: It’s up to you 
I
R
R 

*
1
T
R
R 
1
51
2D Geometric Transformations
Inverse Transformations (cont.)
 2D Inverse Scaling Matrix
 Of course:


















1
0
0
0
1
0
0
0
1
1
y
x
s
s
S
I
S
S 

*
1
52
2D Geometric Transformations
2D Composite Transformations
 We can setup a sequence of transformations
as a composite transformation matrix by
calculating the product of the individual
transformations
 P’=M2·M1·P
=M·P
53
2D Geometric Transformations
2D Composite Transformations
(cont.)
 Composite 2D Translations
 If two successive translation are applied to a point P,
then the final transformed location P' is calculated as


































1
0
0
1
0
0
1
1
0
0
1
0
0
1
1
0
0
1
0
0
1
2
1
2
1
1
1
2
2
y
y
x
x
y
x
y
x
t
t
t
t
t
t
t
t
P
T
P
T
T
P 





 )
,
(
)
,
(
)
,
(
' 2
1
2
1
1
1
2
2 y
y
x
x
y
x
y
x t
t
t
t
t
t
t
t
54
2D Geometric Transformations
 Composite 2D Rotations























































1
0
0
0
)
cos(
)
sin(
0
)
sin(
)
cos(
1
0
0
0
cos
sin
0
sin
cos
1
0
0
0
cos
sin
0
sin
cos
2
1
2
1
2
1
2
1
1
1
1
1
2
2
2
2
P
R
P 

 )
(
' 2
1 

2D Composite Transformations
(cont.)
55
2D Geometric Transformations
 Composite 2D Scaling


































1
0
0
0
0
0
0
1
0
0
0
0
0
0
1
0
0
0
0
0
0
2
1
2
1
1
1
2
2
y
y
x
x
y
x
y
x
s
s
s
s
s
s
s
s
)
,
(
)
,
(
)
,
( 2
1
2
1
1
1
2
2 y
y
x
x
y
x
y
x s
s
s
s
s
s
s
s 


 S
S
S
2D Composite Transformations
(cont.)
56
2D Geometric Transformations
 Don’t forget:
 Successive translations are additive
 Successive scalings are multiplicative
 For example: If we triple the size of an object
twice, the final size is nine (9) times the original
 9 times?
 Why?
 Proof: Again up to you 
2D Composite Transformations
(cont.)
57
2D Geometric Transformations
General Pivot Point Rotation
 Steps:
1. Translate the object so that the pivot point is
moved to the coordinate origin.
2. Rotate the object about the origin.
3. Translate the object so that the pivot point is
returned to its original position.
58
2D Geometric Transformations
General Pivot Point Rotation
59
2D Geometric Transformations
 General 2D Pivot-Point Rotation







































1
0
0
1
0
0
1
1
0
0
0
cos
sin
0
sin
cos
1
0
0
1
0
0
1
r
r
r
r
y
x
y
x
























1
0
0
sin
)
cos
1
(
cos
sin
sin
)
cos
1
(
sin
cos
r
r
r
r
x
y
y
x
2D Composite Transformations
(cont.)
60
2D Geometric Transformations
General Fixed Point Scaling
 Steps:
1. Translate the object so that the fixed point
coincides with the coordinate origin.
2. Scale the object about the origin.
3. Translate the object so that the pivot point is
returned to its original position.
61
2D Geometric Transformations
General Fixed Point Scaling
(cont.)
(xr, yr) (xr, yr)
62
2D Geometric Transformations
1 0 𝑥𝑓
0 1 𝑦𝑓
0 0 1
.
𝑠𝑥 0 0
0 𝑠𝑦 0
0 0 1
.
1 0 − 𝑥𝑓
0 1 − 𝑦𝑓
0 0 1
=
𝑠𝑥 0 𝑥𝑓(1 − 𝑠𝑥)
0 𝑠𝑦 𝑦𝑓(1 − 𝑠𝑦)
0 0 1
𝐓(𝑥𝑓, 𝑦𝑓) ⋅ 𝐒(𝑠𝑥, 𝑠𝑦) ⋅ 𝐓(−𝑥𝑓, −𝑦𝑓) = 𝐒(𝑥𝑓, 𝑦𝑓, 𝑠𝑥, 𝑠𝑦)
• General 2D Fixed-Point Scaling:
General Fixed Point Scaling
(cont.)
63
2D Geometric Transformations
2D Composite Transformations
(cont.)
 General 2D scaling directions:
 Above: scaling parameters were along x and y
directions
 What about arbitrary directions?
 Answer: See next slides
64
2D Geometric Transformations
General 2D Scaling Directions
Scaling parameters s1 and s2 along orthogonal directions defined by the
angular displacement θ. 65
2D Geometric Transformations
General 2D Scaling Directions
(cont.)
 General procedure:
1. Rotate so that directions coincides with x and y
axes
2. Apply scaling transformation 𝑆 𝑠1, 𝑠2
3. Rotate back
 The composite matrix:
𝑅−1 Θ ∗ 𝑆 𝑠1, 𝑠2 ∗ 𝑅 Θ =
𝑠1 cos2 Θ + 𝑠2 sin2 Θ 𝑠2 − 𝑠1 cos Θ sin Θ 0
𝑠2 − 𝑠1 cos Θ sin Θ 𝑠1 sin2 Θ + 𝑠2 cos2 Θ 0
0 0 1
66
2D Geometric Transformations
2D Composite Transformations
(cont.)
 Matrix Concatenation Properties:
 Matrix multiplication is associative !
 M3· M2· M1= (M3· M2 ) · M1 = M3· ( M2 · M1 )
 A composite matrix can be created by multiplicating left-
to-right (premultiplication) or right-to-left
(postmultiplication)
 Matrix multiplication is not commutative !
 M2 · M1 ≠ M1 · M2
67
2D Geometric Transformations
2D Composite Transformations
(cont.)
 Matrix Concatenation Properties:
 But:
 Two successive rotations
 Two successive translations
 Two successive scalings
 are commutative!
 Why?
 Proof: You got it: Up to you  
68
2D Geometric Transformations
10/5/2022 6
9
Mirror
Plane* => Negate the corresponding coordinate
Mirror through Line* => Reflect through 2 planes intersecting at the axis
Point* => Reflect through 3 planes intersecting at the point
* plane - principal plane, line - X, Y, or Z axes, point - CS origin
P* = [M]P,
where [M] = =
Question: Define the signs (in the matrix)
for the reflections (mirroring) through:
a) x = 0, y = 0, z = 0 planes
b) X, Y, and Z axes
c) the CS origin
33
22
11
0
0
0
0
0
0
m
m
m
1
0
0
0
1
0
0
0
1



Reversing the order
in which a sequence of transformations is performed may affect the transformed
position of an object.
In (a), an object is first translated in the x direction, then rotated counterclockwise
through an angle of 45°.
In (b), the object is first rotated 45° counterclockwise, then translated in the x
direction
70
2D Geometric Transformations
Other 2D Transformations
 Reflection
 Transformation that produces a mirror image of an
object
71
2D Geometric Transformations
 Reflection
 Image is generated relative to an axis of reflection
by rotating the object 180° about the reflection
axis
 Reflection about the line y=0 (the x axis) (previous
slide)











1
0
0
0
1
0
0
0
1
Other 2D Transformations (cont.)
72
2D Geometric Transformations
Other 2D Transformations (cont.)
 Reflection
 Reflection about the line x=0 (the y axis)










1
0
0
0
1
0
0
0
1
73
2D Geometric Transformations
−1 0 0
0 − 1 0
0 0 1
 Reflection about the origin
Other 2D Transformations (cont.)
74
2D Geometric Transformations
 Reflection about the line y=x
0 1 0
1 0 0
0 0 1
Other 2D Transformations (cont.)
75
2D Geometric Transformations
 Reflection about the line y=-x
0 − 1 0
−1 0 0
0 0 1
Other 2D Transformations (cont.)
76
2D Geometric Transformations
 Shear
 Transformation that distorts the shape of an object
such that the transformed shape appears as the
object was composed of internal layers that had
been caused to slide over each other
y
x
(0,1) (1,1)
(1,0)
(0,0)
y
x
(2,1) (3,1)
(1,0)
(0,0)
shx=2
Other 2D Transformations (cont.)
77
2D Geometric Transformations
 Shear
 An x-direction shear relative to the x axis
 An y-direction shear relative to the y axis










1
0
0
0
1
0
0
1
y
sh










1
0
0
0
1
0
0
1 x
sh
y
y
y
sh
x
x x




'
'
Other 2D Transformations (cont.)
78
2D Geometric Transformations
 Shear
 x-direction shear relative to other reference lines









 
1
0
0
0
1
0
*
1 ref
x
x y
sh
sh
 
y
y
y
y
sh
x
x ref
x




'
*
'
Other 2D Transformations (cont.)
79
2D Geometric Transformations
Example
A unit square (a) is transformed to a shifted parallelogram
(b) with shx = 0.5 and yref = −1 in the shear matrix from Slide 56
80
2D Geometric Transformations
 Shear
 y-direction shear relative to the line x = xref











1
0
0
*
1
0
0
1
ref
y
y x
sh
sh
 
ref
y x
x
sh
x
y
x
x




*
'
'
Other 2D Transformations (cont.)
81
2D Geometric Transformations
Example
A unit square (a) is turned into a shifted parallelogram
(b) with parameter values shy = 0.5 and xref = −1 in the y -direction shearing
transformation from Slide 58
82
2D Geometric Transformations
 This slide is intentionally left blank
 Your responsibility to fill it 
Raster Methods for
Transformations and OpenGL
83
2D Geometric Transformations
Transformation Between
Coordinate Systems
 Individual objects may be defined in their
local cartesian reference system.
 The local coordinates must be transformed
to position the objects within the scene
coordinate system.
84
2D Geometric Transformations
Steps for coordinate transformation
1. Translate so that the origin (x0, y0 ) of the
x′-y′ system is moved to the origin of the
x-y system.
2.Rotate the x′ axis on to the axis x.
Transformation Between
Coordinate Systems
85
2D Geometric Transformations
y
x
θ
x0
y0
0
Transformation Between
Coordinate Systems (cont.)
86
2D Geometric Transformations
y
x
x0
y0
0
θ
Transformation Between
Coordinate Systems (cont.)
87
2D Geometric Transformations
y
x
x′ x0
y0
0
y′
Transformation Between
Coordinate Systems (cont.)
88
2D Geometric Transformations
𝐓(−𝑥0, −𝑦0) =
1 0 − 𝑥0
0 1 − 𝑦0
0 0 1
𝐑(−𝜃) =
𝐶𝑜𝑠𝜃 𝑆𝑖𝑛𝜃 0
−𝑆𝑖𝑛𝜃 𝐶𝑜𝑠𝜃 0
0 0 1
𝐌𝑥𝑦,𝑥′𝑦′ = 𝐑(−𝜃) ⋅ 𝐓(−𝑥0, −𝑦0)
Transformation Between
Coordinate Systems (cont.)
89
2D Geometric Transformations
An alternative method:
-Specify a vector V that indicates the direction
for the positive y′ axis. Let
-Obtain the unit vector u=(ux ,u y) along the x′
axis by rotating v 900 clockwise.
𝐯 =
𝐕
𝐕
= (𝑣𝑥, 𝑣𝑦)
Transformation Between
Coordinate Systems (cont.)
90
2D Geometric Transformations
 Elements of any rotation matrix can be
expressed as elements of orthogonal unit
vectors. That is, the rotation matrix can be
written as
𝐑 =
𝑢𝑥 𝑢𝑦 0
𝑣𝑥 𝑣𝑦 0
0 0 1
Transformation Between
Coordinate Systems (cont.)
91
2D Geometric Transformations
y
x
x0
y0
0
V
Transformation Between
Coordinate Systems (cont.)
92
2D Geometric Transformations
OpenGL Geometric
Transformation Functions
 A separate function is available for each of the
basic geometric transformations
AND
 All transformations are specified in three
dimensions
 Why?
 Answer: Remember; OpenGL was developed as
3D library
 But how to perform 2D transformations?
 Answer: Set z = 0
93
2D Geometric Transformations
Basic OpenGL Geometric
Transformations
 Translation
 glTranslate* (tx, ty, tz);
 * is either f or d
 tx, ty and tz are any real number
 For 2D, set tz=0.0
 Rotation
 glRotate* (theta, vx, vy, vz);
 * is either f or d
 theta is rotation angle in degrees (internally converted to
radian)
 Vector v=(vx, vy, vz) defines the orientation for a rotation axis
that passes through the coordinate origin
 For 2D, set vz=1.0 and vx=vy=0.0
94
2D Geometric Transformations
Basic OpenGL Geometric
Transformations (cont.)
 Scaling
 glScale* (sx, sy, sz);
 * is either f or d
 sx, sy and sz are any real number
 Negative values generate reflection
 Zero values can cause error because inverse matrix
cannot be calculated
 All routines construct a 4x4 transformation
matrix
 OpenGL uses composite matrices
 Be careful with the order 95
2D Geometric Transformations
OpenGL Matrix Operations
 glMatrixMode(.);
 Projection Mode: Determines how the scene is
projected onto the screen
 Modelview Mode: Used for storing and combining
geometric transformations
 Texture Mode: Used for mapping texture patterns
to surfaces
 Color Mode: Used to convert from one color mode
to another
96
2D Geometric Transformations
OpenGL Matrix Operations
 Modelview matrix, used to store and combine
geometric transformations
 glMatrixMode(GL_MODELVIEW);
 A call to a transformation routine generates a
matrix that is multiplied by the current matrix
 To assign the identity matrix to the current
matrix
 glLoadIdentity();
97
2D Geometric Transformations
OpenGL Matrix Operations
(cont.)
 Alternatively:
 glLoadMatrix* (elements16);
 To assign other values to the elements of the
current matrix
 In column-major order:
 First four elements in first column
 Second four elements in second column
 Third four elements in third column
 Fourth four elements in fourth column
98
2D Geometric Transformations
OpenGL Matrix Operations
(cont.)
 Concatenating a specified matrix with current
matrix:
 glMultMatrix* (otherElements16);
 Current matrix is postmultiplied (right-to-left) by
the specified matrix
 Warning:
 Matrix notation mjk means:
 In OpenGL: j  column, k  row
 In mathematics: j  row, k  column
99
2D Geometric Transformations
OpenGL Matrix Stacks
 OpenGL maintains a matrix stack for
transformations
 Initially the modelview stack contains only the
identity matrix
 More about it:
 Coming soon
100
2D Geometric Transformations
OpenGL Transformation Routines
 For example, assume we want to do in the following
order:
 translate by +2, -3, +4,
 rotate by 450 around axis formed between origin and 1, 1, 1
 scale with respect to the origin by 2 in each direction.
 Our code would be
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); //start with identity
glScalef(2.0,2.0,2.0); //Note: Start with the LAST operation
glRotatef(45.0,1.0,1.0,1.0);
glTranslatef(2.0,-3.0, 4.0); //End with the FIRST operation
101
2D Geometric Transformations
OpenGL Transformation Functions
102
2D Geometric Transformations
Next Lecture
3D Geometric Transformations
103
References
 Donald Hearn, M. Pauline Baker, Warren R.
Carithers, “Computer Graphics with OpenGL, 4th
Edition”; Pearson, 2011
 Sumanta Guha, “Computer Graphics Through
OpenGL: From Theory to Experiments”, CRC Press,
2010
 Edward Angel, “Interactive Computer Graphics. A
Top-Down Approach Using OpenGL”, Addison-
Wesley, 2005
104
Ex. 1: Rotation of object about arbitrary point P (x, y) by θ
> Translate point (x, y) to origin
by (-x, -y)
> Rotate by θ
> Translate the point by (x, y)
6. Reflections/Mirroring
More Reflections
3 D - Rigid body transformations
 Methods for object modeling transformation in three dimensions
are extended from two dimensional methods by including
consideration for the z coordinate.
 Preserve lines, angles and distances.
# Generalize from 2D by including z
coordinate
# Straight forward for translation and
scale
# Rotation more difficult
# Homogeneous coordinates: 4
components
# Transformation matrices: 4×4
éléments.
3D Point:
 We will consider points as column vectors.
 Thus, a typical point with coordinates (x, y, z) is
represented as:
3D Point Homogenous Coordinate:
 A 3D point P is represented in homogeneous
coordinates by a 4-dim, Vector.
 We don't lose anything.
 The main advantage: it is easier to compose
translation and rotation.
 Everything is matrix multiplication.
i. 3D Translation
 In homogeneous coordinates, 3D transformations are represented by
4×4 matrixes:.
 P is translated to P' by:
 An object is translated in 3D
dimensional by transforming
each of the defining points of
the objects .
Cont’d…
# An object represented as a set of polygon surfaces, is translated by
translate each vertex of each surface and redraw the polygon
facets in the new position.
ii. 3D Rotation
 In general, rotations are specified by a rotation axis and an angle.
 In two-dimensions there is only one choice of a rotation axis that leaves
points in the plane.
 The easiest rotation axes are those that parallel to the coordinate axis.
 Positive rotation angles produce counterclockwise rotations about a
coordinate axis, if we are looking along the positive half of the axis
toward the coordinate origin.
Rotation about Z-axis:
:For z axis same as 2D
rotation:
P′ = Rz(θ) ⋅P
Rotation about X-axis:
P′ = Rx(θ) ⋅P
Cont’d…
• Y-axis rotation:
X’ cos(θ) 0 -sin(θ) 0
Y’ = 0 1 0 0
Z’ sin(θ) 0 cos(θ) 0
1 0 0 0 1
General 3D Rotations about axis // to Coordinate Axis
 Rotation axis parallel with coordinate axis (Example x axis):
iii. 3D Scaling
# About origin: changes the size of the object and repositions the
object relative to the coordinate original.
P′ = S ⋅ P
• Scale about any arbitrary point:
iV. 3D Reflections
 About an axis: equivalent to 180°rotation about that axis.
 About a plane: A reflection through the xy plane.
 A reflections through the xz and the yz planes are defined
similarly.
Exercise
 You sat in the car, and find the side mirror 40mm on your
right and 30mm in your front. You started your car and drove
200mm forward, turned 30 degrees to right, moved 200mm
forward again, and turned 45 degrees to the right, and
stopped.
 What is the position of the side mirror now, relative to where
you were sitting in the beginning?
Solution
# The side mirror position is locally (40, 30).
# The matrix of first driving forward 200mm is:
Cont’d…
 The matrix to turn to the right 30 deg and 45 degrees
(rotating -30 and -45 degrees about the origin) are:
The 3rd transformation is moving
by 200mm along an axis oriented 60
degree with the x-axis.
Part 2- Transformation.pptx

More Related Content

Similar to Part 2- Transformation.pptx

GeometricTransformations.ppt
GeometricTransformations.pptGeometricTransformations.ppt
GeometricTransformations.pptDebjit Doira
 
2D Transformation
2D Transformation2D Transformation
2D TransformationShahDhruv21
 
3 d transformation
3 d transformation3 d transformation
3 d transformationPooja Dixit
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphicssabbirantor
 
Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer GraphicsJatenderKhatri
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphicscairo university
 
2d-transformation
2d-transformation2d-transformation
2d-transformationPooja Dixit
 
Computer graphic
Computer graphicComputer graphic
Computer graphicnusratema1
 
Scaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical imageScaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical imageacijjournal
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transformPatel Punit
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D2013901097
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 
3 d transformation
3 d transformation3 d transformation
3 d transformationPooja Dixit
 

Similar to Part 2- Transformation.pptx (20)

GeometricTransformations.ppt
GeometricTransformations.pptGeometricTransformations.ppt
GeometricTransformations.ppt
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
3 d transformation
3 d transformation3 d transformation
3 d transformation
 
06.Transformation.ppt
06.Transformation.ppt06.Transformation.ppt
06.Transformation.ppt
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
 
Transformations in Computer Graphics
Transformations in Computer GraphicsTransformations in Computer Graphics
Transformations in Computer Graphics
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphics
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
3 D Graphics
3 D Graphics3 D Graphics
3 D Graphics
 
2d-transformation
2d-transformation2d-transformation
2d-transformation
 
Computer graphic
Computer graphicComputer graphic
Computer graphic
 
Scaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical imageScaling Transform Methods For Compressing a 2D Graphical image
Scaling Transform Methods For Compressing a 2D Graphical image
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transform
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
Computer Graphics - transformations in 2d
Computer Graphics - transformations in 2dComputer Graphics - transformations in 2d
Computer Graphics - transformations in 2d
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
3 d transformation
3 d transformation3 d transformation
3 d transformation
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 

More from Khalil Alhatab

LE03 The silicon substrate and adding to itPart 2.pptx
LE03 The silicon substrate and adding to itPart 2.pptxLE03 The silicon substrate and adding to itPart 2.pptx
LE03 The silicon substrate and adding to itPart 2.pptxKhalil Alhatab
 
Design Optimization.ppt
Design Optimization.pptDesign Optimization.ppt
Design Optimization.pptKhalil Alhatab
 
Lecture 4 MACHINE TOOL DRIVES.pptx
Lecture 4 MACHINE TOOL DRIVES.pptxLecture 4 MACHINE TOOL DRIVES.pptx
Lecture 4 MACHINE TOOL DRIVES.pptxKhalil Alhatab
 
89-metrology-and-measurements.ppt
89-metrology-and-measurements.ppt89-metrology-and-measurements.ppt
89-metrology-and-measurements.pptKhalil Alhatab
 
vvvvvvvvvvvvvvvchapter-1-190110110813.pdf
vvvvvvvvvvvvvvvchapter-1-190110110813.pdfvvvvvvvvvvvvvvvchapter-1-190110110813.pdf
vvvvvvvvvvvvvvvchapter-1-190110110813.pdfKhalil Alhatab
 
Chapter - 1 Basic Concepts.pdf
Chapter - 1 Basic Concepts.pdfChapter - 1 Basic Concepts.pdf
Chapter - 1 Basic Concepts.pdfKhalil Alhatab
 
15723120156. Measurement of Force and Torque.pdf
15723120156. Measurement of Force and Torque.pdf15723120156. Measurement of Force and Torque.pdf
15723120156. Measurement of Force and Torque.pdfKhalil Alhatab
 
3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdf
3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdf3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdf
3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdfKhalil Alhatab
 
15694598371.Measurment.pdf
15694598371.Measurment.pdf15694598371.Measurment.pdf
15694598371.Measurment.pdfKhalil Alhatab
 
Chapter 4 Angular Measurement.pdf
Chapter 4 Angular Measurement.pdfChapter 4 Angular Measurement.pdf
Chapter 4 Angular Measurement.pdfKhalil Alhatab
 

More from Khalil Alhatab (20)

LE03 The silicon substrate and adding to itPart 2.pptx
LE03 The silicon substrate and adding to itPart 2.pptxLE03 The silicon substrate and adding to itPart 2.pptx
LE03 The silicon substrate and adding to itPart 2.pptx
 
lecture7.ppt
lecture7.pptlecture7.ppt
lecture7.ppt
 
Design Optimization.ppt
Design Optimization.pptDesign Optimization.ppt
Design Optimization.ppt
 
Lecture 4 MACHINE TOOL DRIVES.pptx
Lecture 4 MACHINE TOOL DRIVES.pptxLecture 4 MACHINE TOOL DRIVES.pptx
Lecture 4 MACHINE TOOL DRIVES.pptx
 
ch01.pdf
ch01.pdfch01.pdf
ch01.pdf
 
L-031.pdf
L-031.pdfL-031.pdf
L-031.pdf
 
Part_1a.ppt
Part_1a.pptPart_1a.ppt
Part_1a.ppt
 
Lecture 3.pdf
Lecture 3.pdfLecture 3.pdf
Lecture 3.pdf
 
Lecture 3.pdf
Lecture 3.pdfLecture 3.pdf
Lecture 3.pdf
 
89-metrology-and-measurements.ppt
89-metrology-and-measurements.ppt89-metrology-and-measurements.ppt
89-metrology-and-measurements.ppt
 
vvvvvvvvvvvvvvvchapter-1-190110110813.pdf
vvvvvvvvvvvvvvvchapter-1-190110110813.pdfvvvvvvvvvvvvvvvchapter-1-190110110813.pdf
vvvvvvvvvvvvvvvchapter-1-190110110813.pdf
 
section1.1.pdf
section1.1.pdfsection1.1.pdf
section1.1.pdf
 
Chapter - 1 Basic Concepts.pdf
Chapter - 1 Basic Concepts.pdfChapter - 1 Basic Concepts.pdf
Chapter - 1 Basic Concepts.pdf
 
METRO20152_CH3.pdf
METRO20152_CH3.pdfMETRO20152_CH3.pdf
METRO20152_CH3.pdf
 
15723120156. Measurement of Force and Torque.pdf
15723120156. Measurement of Force and Torque.pdf15723120156. Measurement of Force and Torque.pdf
15723120156. Measurement of Force and Torque.pdf
 
3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdf
3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdf3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdf
3141901-chapter-1_introduction-to-metrology-linear-and-angular-measurement.pdf
 
99995204.pdf
99995204.pdf99995204.pdf
99995204.pdf
 
6570550.ppt
6570550.ppt6570550.ppt
6570550.ppt
 
15694598371.Measurment.pdf
15694598371.Measurment.pdf15694598371.Measurment.pdf
15694598371.Measurment.pdf
 
Chapter 4 Angular Measurement.pdf
Chapter 4 Angular Measurement.pdfChapter 4 Angular Measurement.pdf
Chapter 4 Angular Measurement.pdf
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 

Part 2- Transformation.pptx

  • 1. Part - #2 Geometric Transformation (2D & 3D) March, 2019
  • 2. 10/5/2022 2 Intro & General Information Geometric Transformations Construction (translate, rotate, scale, mirror) Viewing (projections, zooming) Animation (processes, vibration)
  • 3. Coordinate Systems  In order to specify the geometry of a given solid, it is necessary to use a variety of coordinate systems. Its Major classifications are:  World Coordinate System: Also known as the "universe" or sometimes "model" coordinate system. This is the base reference system for the overall model, ( generally in 3D ), to which all other model coordinates relate  User Coordinate System: Also known as “working” coordinate system. When it is difficult to define certain geometries using WCS, In such cases user coordinate system can be defined relative to the WCS.  Display Coordinates: This refers to the actual coordinates to be used for displaying the image on the screen.
  • 4. 10/5/2022 4 General Information Transformation of a point is basic in GT. It can be formulated as follows: Given a point P that belongs to a geometric model find the corresponding point P* in the new position such that P* = f(P, transformation parameters) • The transformation parameters should provide ONE-TO-ONE- MAPPING. • Multiple transformations can be combined to yield a single transformation which should have the same effect as the sequential application of original ones. CONCATENATION /kənˌkatnˈāSH(ə)n/ Equation of P* for graphics hardware should be in matrix notation: P* = [T]P, where [T] is the transformation matrix.
  • 5. Geometric Transformations  Sometimes also called modeling transformations  Geometric transformations: Changing an object’s position (translation), orientation (rotation) or size (scaling)  Modeling transformations: Constructing a scene or hierarchical description of a complex object  Others transformations: reflection and shearing operations 5
  • 6. 1. Geometric Transformations  What is transformation? > It is the backbone of computer graphics, enabling us to manipulate the shape, size, and location of the object. > Changing something to something else via rules.  Why are they important to graphics? > It can be used to effect the following changes in a geometric object: 1. Change the location 2. Change the shape 3. Change the size 4. Rotate
  • 7. 2. Types of Transformations i. Geometric/Object Transformation > This transformation alters the coordinate values of the object. Basic operations are scaling, translation, rotation and combination of one or more of these basic transformations. > Object transformation = Move (transform) an object in the 2D/3D space. ii. Visual/ Coordinate System Transformation > In this transformation there is no change in either the geometry or the coordinates of the object. A copy of the object is placed at the desired sight, without changing the coordinate values of the object. > Coordinate system transformation = Move (transform) the coordinate system. View the objects from the new coordinate system.
  • 8. 8 3. Types of Geometric Transformations  Translation  Rotation  Scaling  Reflection/Mirroring.
  • 9. 10/5/2022 9 Translation Translation is a rigid-body transformation (Euclidean) when each entity of the model remains parallel, or each point moves an equal distance in a given direction: P* = P + d (for both 2D and 3D). In a scalar form (for 3D): x* = x + xd y* = y + yd z* = z + zd C (11,7) A (8,5) B (10,8) A* C* B* y x O Question: Find the coordinates of vertices A*, B*, and C* of the translated triangle. The distance vector of translation: D = [-7 -4]T. Verify that the lengths of the edges are unchanged.
  • 10. i. Translation - 2D Moving an object is called a translation. We translate a point by adding to the x and y coordinates, respectively, the amount the point should be shifted in the x and y directions. We translate an object by translating each vertex in the object.
  • 11. Basic 2D Geometric Transformations  2D Translation  x’ = x + tx , y’ = y + ty  P’=P+T  Translation moves the object without deformation (rigid-body transformation) P P’ T                      y x t t T y x P y x P , ' ' ' , 11
  • 12. Basic 2D Geometric Transformations (cont.)  2D Translation  To move a line segment, apply the transformation equation to each of the two line endpoints and redraw the line between new endpoints  To move a polygon, apply the transformation equation to coordinates of each vertex and regenerate the polygon using the new set of vertex coordinates 12
  • 13. Scaling is used to change the size of an entity or a model. P* = [S]P sx 0 0 For general case [S] = 0 sy 0 , 0 0 sz If 0 < s < 1 - compression If s > 1 - stretching sx = sy = sz - uniform scaling, otherwise - non-uniform 10/5/2022 13 Scaling where sx, sy, and sz are the scaling factors in the X, Y, and Z directions respectively. Question: The larger circle is the scaled copy of the smaller one. Can you say that we have a uniform scaling? Why? Define y* and R*. O(4,2) O*(10,y*) O x y R 1 R*
  • 14. ii. Scaling > Changing the size of an object is called a scale. We scale an object by scaling the x and y coordinates of each vertex in the object.
  • 15.  2D Rotation  Rotation axis  Rotation angle  rotation point or pivot point (xr,yr) yr xr θ Basic 2D Geometric Transformations (cont.) 15 2D Geometric Transformations
  • 16.  2D Rotation  If θ is positive  counterclockwise rotation  If θ is negative  clockwise rotation  Remember:  cos(a + b) = cos a cos b - sin a sin b  cos(a - b) = cos a sin b + sin a cos b Basic 2D Geometric Transformations (cont.) 16 2D Geometric Transformations
  • 17. 10/5/2022 17 Rotation Rotation is a non-commutative transformation (depends on sequence).                                                                                                                                                             cos 0 sin 0 1 0 sin 0 cos cos sin 0 sin cos 0 0 0 1 1 0 0 0 cos sin 0 sin cos cos sin sin cos cos sin sin cos sin sin cos cos ) sin( ) cos( P sin cos P P P * * * * * y x z R R R z y x y x z r r r r z r r z y x z r r z y x R   P* P x y* x* y X Y Z Question: Let the length of a major and minor axes of an ellipse with the center on the origin of the CS be 2a and 2b respectively, and  - the angle between the major axis and the x-axis. Then, derive the expression of an ellipse in the (O,x,y) system.
  • 18. iii. Rotation about the origin ø Consider rotation about the origin by Θ degrees ø Radius stays the same, angle increases by Θ.
  • 19.  2D Rotation  At first, suppose the pivot point is at the origin  x’=r cos(θ+Φ) = r cos θ cos Φ - r sin θ sin Φ y’=r sin(θ+Φ) = r cos θ sin Φ + r sin θ cos Φ  x = r cos Φ, y = r sin Φ  x’=x cos θ - y sin θ y’=x sin θ + y cos θ Φ (x,y) r r θ (x’,y’) Basic 2D Geometric Transformations (cont.) 19 2D Geometric Transformations
  • 20. Basic 2D Geometric Transformations  2D Rotation  P’=R·P             cos sin sin cos R Φ (x,y) r r θ (x’,y’) 20 2D Geometric Transformations
  • 22. Cont’d… Example: • Translate the rectangle (2, 2), (2, 8), (10, 8), (10, 2) 2 units along x-axis and 3 units along y-axis.
  • 24.  2D Scaling  Scaling is used to alter the size of an object  Simple 2D scaling is performed by multiplying object positions (x, y) by scaling factors sx and sy x’ = x · sx y’ = y · sx or P’ = S·P                     y x s s y x y x 0 0 ' ' Basic 2D Geometric Transformations (cont.) 24
  • 25.  2D Scaling  Any positive value can be used as scaling factor  Values less than 1 reduce the size of the object  Values greater than 1 enlarge the object  If scaling factor is 1 then the object stays unchanged  If sx = sy , we call it uniform scaling  If scaling factor <1, then the object moves closer to the origin and If scaling factor >1, then the object moves farther from the origin x’ x Basic 2D Geometric Transformations (cont.) 25
  • 26.  2D Scaling  Why does scaling also reposition object?  Answer: See the matrix (multiplication)  Still no clue?  𝑥′ 𝑦′ = 𝑠𝑥 0 0 𝑠𝑦 ∗ 𝑥 𝑦 = 𝑥 ∗ 𝑠𝑥 + 𝑦 ∗ 0 𝑥 ∗ 0 + 𝑦 ∗ 𝑠𝑦 Basic 2D Geometric Transformations (cont.) 26
  • 27.  2D Scaling  We can control the location of the scaled object by choosing a position called the fixed point (xf,yf) x’ – xf = (x – xf) sx y’ – yf = (y – yf) sy x’=x · sx + xf (1 – sx) y’=y · sy + yf (1 – sy)  Polygons are scaled by applying the above formula to each vertex, then regenerating the polygon using the transformed vertices Basic 2D Geometric Transformations (cont.) 27
  • 28. Example:  If the triangle A(1, 1), B(2, 1), C(1, 3) is scaled by a factor 2, find the new coordinates of the triangle.
  • 30. Cont’d… Example: • Rotate the rectangle (0, 0), (2, 0), (2, 2), (0, 2) by 30o ccw about its centroid and find the new coordinates of the rectangle.
  • 32. 4. Homogeneous Coordinates > In order to represent a translation as a matrix multiplication operation we use 3 x 3 matrices and pad the points to become 3 x 1 matrices. > This coordinate system (using three values to represent a 2D point) is called homogeneous coordinates. > Let the added extra coordinate be W, to a point: P (x, y, W). > Two sets of homogeneous coordinates represent the same point if they are a multiple of each other. > If W ≠ 0 , divide by it to get Cartesian coordinates of point: (x/W, y/W, 1). > If W = 0, point is said to be at infinity.
  • 33. Cont’d… Transformation matrices for 2D translation are now 3x3.
  • 34. 5. Concatenation of transformation
  • 37. Homogeneous form of scale Concatenation of scales
  • 38.
  • 39. 10/5/2022 39 Homogeneous Transformation When we scale then rotate, the transformed image is given by: P* = ([R][S])P where [S], [R], [R] [S] are 3x3 transformation matrices. This is not the case for a translation (P* = P + d). The goal is to find a [D] such that P + d = [D]P in order to perform valid matrix multiplication. This is found by using a homogeneous coordinates. Homogeneous Transformation maps n-dimensional space into (n+1)- dim. 3D representation of the point vector - P = [x, y, z]T Homogeneous rep. of the same vector - P = [xw, yw, zw, w]T where w = 1
  • 40. Matrix Representations and Homogeneous Coordinates  Many graphics applications involve sequences of geometric transformations  Animations  Design and picture construction applications  We will now consider matrix representations of these operations  Sequences of transformations can be efficiently processed using matrices 40 2D Geometric Transformations
  • 41. Matrix Representations and Homogeneous Coordinates (cont.)  P’ = M1 · P + M2  P and P’ are column vectors  M1 is a 2 by 2 array containing multiplicative factors  M2 is a 2 element column matrix containing translational terms  For translation M1 is the identity matrix  For rotation or scaling, M2 contains the translational terms associated with the pivot point or scaling fixed point 41 2D Geometric Transformations
  • 42.  To produce a sequence of operations, such as scaling followed by rotation then translation, we could calculate the transformed coordinates one step at a time  A more efficient approach is to combine transformations, without calculating intermediate coordinate values Matrix Representations and Homogeneous Coordinates (cont.) 42 2D Geometric Transformations
  • 43.  Multiplicative and translational terms for a 2D geometric transformation can be combined into a single matrix if we expand the representations to 3 by 3 matrices  We can use the third column for translation terms, and all transformation equations can be expressed as matrix multiplications Matrix Representations and Homogeneous Coordinates (cont.) 43 2D Geometric Transformations
  • 44.  Expand each 2D coordinate (x,y) to three element representation (xh,yh,h) called homogeneous coordinates  h is the homogeneous parameter such that x = xh/h, y = yh/h,   infinite homogeneous representations for a point  A convenient choice is to choose h = 1 Matrix Representations and Homogeneous Coordinates (cont.) 44 2D Geometric Transformations
  • 45. 10/5/2022 45 Homogeneous Transformation The transformation matrices in new (homogeneous) representation:                                                                1 0 0 0 0 0 0 R 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 33 32 31 23 22 21 13 12 11 r r r r r r r r r M s s s S z y x D z y x d d d
  • 46.  2D Translation Matrix or, P’ = T(tx,ty)·P                                 1 1 0 0 1 0 0 1 1 ' ' y x t t y x y x Matrix Representations and Homogeneous Coordinates (cont.) 46 2D Geometric Transformations
  • 47.  2D Rotation Matrix or, P’ = R(θ)·P                                      1 1 0 0 0 cos sin 0 sin cos 1 ' ' y x y x Matrix Representations and Homogeneous Coordinates (cont.) 47 2D Geometric Transformations
  • 48.  2D Scaling Matrix or, P’ = S(sx,sy)·P                                 1 1 0 0 0 0 0 0 1 ' ' y x s s y x y x Matrix Representations and Homogeneous Coordinates (cont.) 48 2D Geometric Transformations
  • 49. Inverse Transformations  2D Inverse Translation Matrix  By the way:               1 0 0 1 0 0 1 1 y x t t T I T T   * 1 49 2D Geometric Transformations
  • 50. Inverse Transformations (cont.)  2D Inverse Rotation Matrix  And also:                  1 0 0 0 cos sin 0 sin cos 1 R I R R   * 1 50 2D Geometric Transformations
  • 51. Inverse Transformations (cont.)  2D Inverse Rotation Matrix:  If θ is negative  clockwise  In  Only sine function is affected  Therefore we can say  Is that true?  Proof: It’s up to you  I R R   * 1 T R R  1 51 2D Geometric Transformations
  • 52. Inverse Transformations (cont.)  2D Inverse Scaling Matrix  Of course:                   1 0 0 0 1 0 0 0 1 1 y x s s S I S S   * 1 52 2D Geometric Transformations
  • 53. 2D Composite Transformations  We can setup a sequence of transformations as a composite transformation matrix by calculating the product of the individual transformations  P’=M2·M1·P =M·P 53 2D Geometric Transformations
  • 54. 2D Composite Transformations (cont.)  Composite 2D Translations  If two successive translation are applied to a point P, then the final transformed location P' is calculated as                                   1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 0 1 0 0 1 2 1 2 1 1 1 2 2 y y x x y x y x t t t t t t t t P T P T T P        ) , ( ) , ( ) , ( ' 2 1 2 1 1 1 2 2 y y x x y x y x t t t t t t t t 54 2D Geometric Transformations
  • 55.  Composite 2D Rotations                                                        1 0 0 0 ) cos( ) sin( 0 ) sin( ) cos( 1 0 0 0 cos sin 0 sin cos 1 0 0 0 cos sin 0 sin cos 2 1 2 1 2 1 2 1 1 1 1 1 2 2 2 2 P R P    ) ( ' 2 1   2D Composite Transformations (cont.) 55 2D Geometric Transformations
  • 56.  Composite 2D Scaling                                   1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 2 1 2 1 1 1 2 2 y y x x y x y x s s s s s s s s ) , ( ) , ( ) , ( 2 1 2 1 1 1 2 2 y y x x y x y x s s s s s s s s     S S S 2D Composite Transformations (cont.) 56 2D Geometric Transformations
  • 57.  Don’t forget:  Successive translations are additive  Successive scalings are multiplicative  For example: If we triple the size of an object twice, the final size is nine (9) times the original  9 times?  Why?  Proof: Again up to you  2D Composite Transformations (cont.) 57 2D Geometric Transformations
  • 58. General Pivot Point Rotation  Steps: 1. Translate the object so that the pivot point is moved to the coordinate origin. 2. Rotate the object about the origin. 3. Translate the object so that the pivot point is returned to its original position. 58 2D Geometric Transformations
  • 59. General Pivot Point Rotation 59 2D Geometric Transformations
  • 60.  General 2D Pivot-Point Rotation                                        1 0 0 1 0 0 1 1 0 0 0 cos sin 0 sin cos 1 0 0 1 0 0 1 r r r r y x y x                         1 0 0 sin ) cos 1 ( cos sin sin ) cos 1 ( sin cos r r r r x y y x 2D Composite Transformations (cont.) 60 2D Geometric Transformations
  • 61. General Fixed Point Scaling  Steps: 1. Translate the object so that the fixed point coincides with the coordinate origin. 2. Scale the object about the origin. 3. Translate the object so that the pivot point is returned to its original position. 61 2D Geometric Transformations
  • 62. General Fixed Point Scaling (cont.) (xr, yr) (xr, yr) 62 2D Geometric Transformations
  • 63. 1 0 𝑥𝑓 0 1 𝑦𝑓 0 0 1 . 𝑠𝑥 0 0 0 𝑠𝑦 0 0 0 1 . 1 0 − 𝑥𝑓 0 1 − 𝑦𝑓 0 0 1 = 𝑠𝑥 0 𝑥𝑓(1 − 𝑠𝑥) 0 𝑠𝑦 𝑦𝑓(1 − 𝑠𝑦) 0 0 1 𝐓(𝑥𝑓, 𝑦𝑓) ⋅ 𝐒(𝑠𝑥, 𝑠𝑦) ⋅ 𝐓(−𝑥𝑓, −𝑦𝑓) = 𝐒(𝑥𝑓, 𝑦𝑓, 𝑠𝑥, 𝑠𝑦) • General 2D Fixed-Point Scaling: General Fixed Point Scaling (cont.) 63 2D Geometric Transformations
  • 64. 2D Composite Transformations (cont.)  General 2D scaling directions:  Above: scaling parameters were along x and y directions  What about arbitrary directions?  Answer: See next slides 64 2D Geometric Transformations
  • 65. General 2D Scaling Directions Scaling parameters s1 and s2 along orthogonal directions defined by the angular displacement θ. 65 2D Geometric Transformations
  • 66. General 2D Scaling Directions (cont.)  General procedure: 1. Rotate so that directions coincides with x and y axes 2. Apply scaling transformation 𝑆 𝑠1, 𝑠2 3. Rotate back  The composite matrix: 𝑅−1 Θ ∗ 𝑆 𝑠1, 𝑠2 ∗ 𝑅 Θ = 𝑠1 cos2 Θ + 𝑠2 sin2 Θ 𝑠2 − 𝑠1 cos Θ sin Θ 0 𝑠2 − 𝑠1 cos Θ sin Θ 𝑠1 sin2 Θ + 𝑠2 cos2 Θ 0 0 0 1 66 2D Geometric Transformations
  • 67. 2D Composite Transformations (cont.)  Matrix Concatenation Properties:  Matrix multiplication is associative !  M3· M2· M1= (M3· M2 ) · M1 = M3· ( M2 · M1 )  A composite matrix can be created by multiplicating left- to-right (premultiplication) or right-to-left (postmultiplication)  Matrix multiplication is not commutative !  M2 · M1 ≠ M1 · M2 67 2D Geometric Transformations
  • 68. 2D Composite Transformations (cont.)  Matrix Concatenation Properties:  But:  Two successive rotations  Two successive translations  Two successive scalings  are commutative!  Why?  Proof: You got it: Up to you   68 2D Geometric Transformations
  • 69. 10/5/2022 6 9 Mirror Plane* => Negate the corresponding coordinate Mirror through Line* => Reflect through 2 planes intersecting at the axis Point* => Reflect through 3 planes intersecting at the point * plane - principal plane, line - X, Y, or Z axes, point - CS origin P* = [M]P, where [M] = = Question: Define the signs (in the matrix) for the reflections (mirroring) through: a) x = 0, y = 0, z = 0 planes b) X, Y, and Z axes c) the CS origin 33 22 11 0 0 0 0 0 0 m m m 1 0 0 0 1 0 0 0 1   
  • 70. Reversing the order in which a sequence of transformations is performed may affect the transformed position of an object. In (a), an object is first translated in the x direction, then rotated counterclockwise through an angle of 45°. In (b), the object is first rotated 45° counterclockwise, then translated in the x direction 70 2D Geometric Transformations
  • 71. Other 2D Transformations  Reflection  Transformation that produces a mirror image of an object 71 2D Geometric Transformations
  • 72.  Reflection  Image is generated relative to an axis of reflection by rotating the object 180° about the reflection axis  Reflection about the line y=0 (the x axis) (previous slide)            1 0 0 0 1 0 0 0 1 Other 2D Transformations (cont.) 72 2D Geometric Transformations
  • 73. Other 2D Transformations (cont.)  Reflection  Reflection about the line x=0 (the y axis)           1 0 0 0 1 0 0 0 1 73 2D Geometric Transformations
  • 74. −1 0 0 0 − 1 0 0 0 1  Reflection about the origin Other 2D Transformations (cont.) 74 2D Geometric Transformations
  • 75.  Reflection about the line y=x 0 1 0 1 0 0 0 0 1 Other 2D Transformations (cont.) 75 2D Geometric Transformations
  • 76.  Reflection about the line y=-x 0 − 1 0 −1 0 0 0 0 1 Other 2D Transformations (cont.) 76 2D Geometric Transformations
  • 77.  Shear  Transformation that distorts the shape of an object such that the transformed shape appears as the object was composed of internal layers that had been caused to slide over each other y x (0,1) (1,1) (1,0) (0,0) y x (2,1) (3,1) (1,0) (0,0) shx=2 Other 2D Transformations (cont.) 77 2D Geometric Transformations
  • 78.  Shear  An x-direction shear relative to the x axis  An y-direction shear relative to the y axis           1 0 0 0 1 0 0 1 y sh           1 0 0 0 1 0 0 1 x sh y y y sh x x x     ' ' Other 2D Transformations (cont.) 78 2D Geometric Transformations
  • 79.  Shear  x-direction shear relative to other reference lines            1 0 0 0 1 0 * 1 ref x x y sh sh   y y y y sh x x ref x     ' * ' Other 2D Transformations (cont.) 79 2D Geometric Transformations
  • 80. Example A unit square (a) is transformed to a shifted parallelogram (b) with shx = 0.5 and yref = −1 in the shear matrix from Slide 56 80 2D Geometric Transformations
  • 81.  Shear  y-direction shear relative to the line x = xref            1 0 0 * 1 0 0 1 ref y y x sh sh   ref y x x sh x y x x     * ' ' Other 2D Transformations (cont.) 81 2D Geometric Transformations
  • 82. Example A unit square (a) is turned into a shifted parallelogram (b) with parameter values shy = 0.5 and xref = −1 in the y -direction shearing transformation from Slide 58 82 2D Geometric Transformations
  • 83.  This slide is intentionally left blank  Your responsibility to fill it  Raster Methods for Transformations and OpenGL 83 2D Geometric Transformations
  • 84. Transformation Between Coordinate Systems  Individual objects may be defined in their local cartesian reference system.  The local coordinates must be transformed to position the objects within the scene coordinate system. 84 2D Geometric Transformations
  • 85. Steps for coordinate transformation 1. Translate so that the origin (x0, y0 ) of the x′-y′ system is moved to the origin of the x-y system. 2.Rotate the x′ axis on to the axis x. Transformation Between Coordinate Systems 85 2D Geometric Transformations
  • 86. y x θ x0 y0 0 Transformation Between Coordinate Systems (cont.) 86 2D Geometric Transformations
  • 87. y x x0 y0 0 θ Transformation Between Coordinate Systems (cont.) 87 2D Geometric Transformations
  • 88. y x x′ x0 y0 0 y′ Transformation Between Coordinate Systems (cont.) 88 2D Geometric Transformations
  • 89. 𝐓(−𝑥0, −𝑦0) = 1 0 − 𝑥0 0 1 − 𝑦0 0 0 1 𝐑(−𝜃) = 𝐶𝑜𝑠𝜃 𝑆𝑖𝑛𝜃 0 −𝑆𝑖𝑛𝜃 𝐶𝑜𝑠𝜃 0 0 0 1 𝐌𝑥𝑦,𝑥′𝑦′ = 𝐑(−𝜃) ⋅ 𝐓(−𝑥0, −𝑦0) Transformation Between Coordinate Systems (cont.) 89 2D Geometric Transformations
  • 90. An alternative method: -Specify a vector V that indicates the direction for the positive y′ axis. Let -Obtain the unit vector u=(ux ,u y) along the x′ axis by rotating v 900 clockwise. 𝐯 = 𝐕 𝐕 = (𝑣𝑥, 𝑣𝑦) Transformation Between Coordinate Systems (cont.) 90 2D Geometric Transformations
  • 91.  Elements of any rotation matrix can be expressed as elements of orthogonal unit vectors. That is, the rotation matrix can be written as 𝐑 = 𝑢𝑥 𝑢𝑦 0 𝑣𝑥 𝑣𝑦 0 0 0 1 Transformation Between Coordinate Systems (cont.) 91 2D Geometric Transformations
  • 92. y x x0 y0 0 V Transformation Between Coordinate Systems (cont.) 92 2D Geometric Transformations
  • 93. OpenGL Geometric Transformation Functions  A separate function is available for each of the basic geometric transformations AND  All transformations are specified in three dimensions  Why?  Answer: Remember; OpenGL was developed as 3D library  But how to perform 2D transformations?  Answer: Set z = 0 93 2D Geometric Transformations
  • 94. Basic OpenGL Geometric Transformations  Translation  glTranslate* (tx, ty, tz);  * is either f or d  tx, ty and tz are any real number  For 2D, set tz=0.0  Rotation  glRotate* (theta, vx, vy, vz);  * is either f or d  theta is rotation angle in degrees (internally converted to radian)  Vector v=(vx, vy, vz) defines the orientation for a rotation axis that passes through the coordinate origin  For 2D, set vz=1.0 and vx=vy=0.0 94 2D Geometric Transformations
  • 95. Basic OpenGL Geometric Transformations (cont.)  Scaling  glScale* (sx, sy, sz);  * is either f or d  sx, sy and sz are any real number  Negative values generate reflection  Zero values can cause error because inverse matrix cannot be calculated  All routines construct a 4x4 transformation matrix  OpenGL uses composite matrices  Be careful with the order 95 2D Geometric Transformations
  • 96. OpenGL Matrix Operations  glMatrixMode(.);  Projection Mode: Determines how the scene is projected onto the screen  Modelview Mode: Used for storing and combining geometric transformations  Texture Mode: Used for mapping texture patterns to surfaces  Color Mode: Used to convert from one color mode to another 96 2D Geometric Transformations
  • 97. OpenGL Matrix Operations  Modelview matrix, used to store and combine geometric transformations  glMatrixMode(GL_MODELVIEW);  A call to a transformation routine generates a matrix that is multiplied by the current matrix  To assign the identity matrix to the current matrix  glLoadIdentity(); 97 2D Geometric Transformations
  • 98. OpenGL Matrix Operations (cont.)  Alternatively:  glLoadMatrix* (elements16);  To assign other values to the elements of the current matrix  In column-major order:  First four elements in first column  Second four elements in second column  Third four elements in third column  Fourth four elements in fourth column 98 2D Geometric Transformations
  • 99. OpenGL Matrix Operations (cont.)  Concatenating a specified matrix with current matrix:  glMultMatrix* (otherElements16);  Current matrix is postmultiplied (right-to-left) by the specified matrix  Warning:  Matrix notation mjk means:  In OpenGL: j  column, k  row  In mathematics: j  row, k  column 99 2D Geometric Transformations
  • 100. OpenGL Matrix Stacks  OpenGL maintains a matrix stack for transformations  Initially the modelview stack contains only the identity matrix  More about it:  Coming soon 100 2D Geometric Transformations
  • 101. OpenGL Transformation Routines  For example, assume we want to do in the following order:  translate by +2, -3, +4,  rotate by 450 around axis formed between origin and 1, 1, 1  scale with respect to the origin by 2 in each direction.  Our code would be glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //start with identity glScalef(2.0,2.0,2.0); //Note: Start with the LAST operation glRotatef(45.0,1.0,1.0,1.0); glTranslatef(2.0,-3.0, 4.0); //End with the FIRST operation 101 2D Geometric Transformations
  • 102. OpenGL Transformation Functions 102 2D Geometric Transformations
  • 103. Next Lecture 3D Geometric Transformations 103
  • 104. References  Donald Hearn, M. Pauline Baker, Warren R. Carithers, “Computer Graphics with OpenGL, 4th Edition”; Pearson, 2011  Sumanta Guha, “Computer Graphics Through OpenGL: From Theory to Experiments”, CRC Press, 2010  Edward Angel, “Interactive Computer Graphics. A Top-Down Approach Using OpenGL”, Addison- Wesley, 2005 104
  • 105. Ex. 1: Rotation of object about arbitrary point P (x, y) by θ > Translate point (x, y) to origin by (-x, -y) > Rotate by θ > Translate the point by (x, y)
  • 108. 3 D - Rigid body transformations  Methods for object modeling transformation in three dimensions are extended from two dimensional methods by including consideration for the z coordinate.  Preserve lines, angles and distances. # Generalize from 2D by including z coordinate # Straight forward for translation and scale # Rotation more difficult # Homogeneous coordinates: 4 components # Transformation matrices: 4×4 éléments.
  • 109. 3D Point:  We will consider points as column vectors.  Thus, a typical point with coordinates (x, y, z) is represented as: 3D Point Homogenous Coordinate:  A 3D point P is represented in homogeneous coordinates by a 4-dim, Vector.  We don't lose anything.  The main advantage: it is easier to compose translation and rotation.  Everything is matrix multiplication.
  • 110. i. 3D Translation  In homogeneous coordinates, 3D transformations are represented by 4×4 matrixes:.  P is translated to P' by:  An object is translated in 3D dimensional by transforming each of the defining points of the objects .
  • 111. Cont’d… # An object represented as a set of polygon surfaces, is translated by translate each vertex of each surface and redraw the polygon facets in the new position.
  • 112. ii. 3D Rotation  In general, rotations are specified by a rotation axis and an angle.  In two-dimensions there is only one choice of a rotation axis that leaves points in the plane.  The easiest rotation axes are those that parallel to the coordinate axis.  Positive rotation angles produce counterclockwise rotations about a coordinate axis, if we are looking along the positive half of the axis toward the coordinate origin.
  • 113. Rotation about Z-axis: :For z axis same as 2D rotation: P′ = Rz(θ) ⋅P Rotation about X-axis: P′ = Rx(θ) ⋅P
  • 114. Cont’d… • Y-axis rotation: X’ cos(θ) 0 -sin(θ) 0 Y’ = 0 1 0 0 Z’ sin(θ) 0 cos(θ) 0 1 0 0 0 1
  • 115. General 3D Rotations about axis // to Coordinate Axis  Rotation axis parallel with coordinate axis (Example x axis):
  • 116. iii. 3D Scaling # About origin: changes the size of the object and repositions the object relative to the coordinate original. P′ = S ⋅ P
  • 117. • Scale about any arbitrary point:
  • 118. iV. 3D Reflections  About an axis: equivalent to 180°rotation about that axis.  About a plane: A reflection through the xy plane.  A reflections through the xz and the yz planes are defined similarly.
  • 119. Exercise  You sat in the car, and find the side mirror 40mm on your right and 30mm in your front. You started your car and drove 200mm forward, turned 30 degrees to right, moved 200mm forward again, and turned 45 degrees to the right, and stopped.  What is the position of the side mirror now, relative to where you were sitting in the beginning?
  • 120. Solution # The side mirror position is locally (40, 30). # The matrix of first driving forward 200mm is:
  • 121. Cont’d…  The matrix to turn to the right 30 deg and 45 degrees (rotating -30 and -45 degrees about the origin) are: The 3rd transformation is moving by 200mm along an axis oriented 60 degree with the x-axis.