SlideShare a Scribd company logo
1 of 56
Transformation
2D and 3D
Dept. of Computer Science and Engineering
Islamic University, Kushtia
Dimensions
x
y
y
x
z
Transformations
 Many applications need altering or manipulating displays
Geometric Transformation Coordinate Transformation
Object Transformed Coordinate Transformed
Transformations
There are two types of Transformation
2D Transformation
 Given a 2D object, transformation is to change the
object’s
 Position (translation)
 Orientation (rotation)
 Size (scaling)
 Shapes (shear)
2D Transformations
How many way the object can be transformed?
Three Basic Types of Transformation
• Translation
• Rotation
• Scaling
Another Transformations are
• Reflection
• Shear
x
y
x
y
x
y
Translation
 Re-position a point along a straight line
 Given a point (x, y), and the translation distance (tx, ty)
(x,y)
(x’,y’)
tx
ty
The new point: (x’, y’)
x’ = x + tx
y’ = y + ty
or P’ = P + T
























y
x
t
t
T
y
x
P
y
x
P ,
,

















y
x
t
y
t
x
y
x
Translation
 How to translate an object with multiple
vertices?
Translate individual
vertices
2D Rotation
 Default rotation center: Origin (0,0)
q
q> 0 : Rotate counter clockwise
q< 0 : Rotate clockwise
q
The rotation point/ Pivot point –
The point at which the object is to be rotate
(Positive Rotation)
(Negative Rotation)
Rotation
(x,y)
(x’,y’)
q
(x,y) -> Rotate about the origin by q
(x’, y’)
How to compute (x’, y’) ? f
x = r cos (f) y = r sin (f)
r
x’ = r cos (f  q) y = r sin (f  q)
Rotation
(x,y)
(x’,y’)
q
f
r
x = r cos (f) y = r sin (f)
x’ = r cos (f  q) y = r sin (f  q)
x’ = r cos (f  q)
= r cos(f) cos(q) – r sin(f) sin(q)
= x cos(q)– y sin(q)
y’ = r sin (f  q)
= r sin(f) cos(q) + r cos(f)sin(q)
= y cos(q) + x sin(q)
Rotation
(x,y)
(x’,y’)
q
f
r
x’ = x cos(q) – y sin(q)
y’ = y cos(q) + x sin(q)
Matrix form?
x’ cos(q) -sin(q) x
y’ sin(q) cos(q) y
=
P/ = R(f). P
Rotation
 How to rotate an object with multiple
vertices?
Rotate individual
Vertices
q
Scaling
Scale: Alter the size of an object by a scaling factor
(Sx, Sy), i.e.
x’ = x . Sx
y’ = y . Sy
(1,1)
(2,2) Sx = 2, Sy = 2
(2,2)
(4,4)



















y
x
s
s
y
x
y
x
0
0
'
'
Fixed point – The point that used to control the location of a scaled object
P/ = S. P
2D Scaling
(1,1)
(2,2) Sx = 2, Sy = 2
(2,2)
(4,4)
 Not only the object size is changed, it also moved!!
 Usually this is an undesirable effect
 We will discuss later (soon) how to fix it
Put it all together

















y
x
t
y
t
x
y
x
Translation:
Rotation:
Scaling: 


















y
x
s
s
y
x
y
x
0
0
'
'
P=T + P
P=S  P
P=R  P











 







y
x
y
x
f
f
f
f
cos
sin
sin
cos
'
'
Matrix Representation and
Homogeneous Coordinates
 Many graphics applications involve sequences of geometric
transformations. Example
 In animation, an object to be translated and rotated at each
increment of the motion.
 In design and picture construction applications, translations,
rotations, and scalings are used to fit the picture components
into their proper positions.
 Rotation and Scaling matrix are 2 by 2 and point P is multiplied with
matrix R or S
 Translation matrix is 2 by 1 and it is add with point P
 The multiplicative and translational terms for two-dimensional
geometric transformations into a single Matrix representation by
expanding the 2 by 2 matrix representations to 3 by 3 matrices.
 This allows us to express all transformation equations as matrix
multiplications
Homogeneous Coordinates
Any 2D transformation can be described uniquely by a 3x3 matrix, if
the Cartesian coordinates (x, y) is represented by the homogeneous
coordinate triple (xh, yh, h),
where
h can be any real value ≠ 0,
for simplicity h=1 is used here
•The term homogeneous coordinates is used in mathematics to refer to the effect of
this representation on Cartesian equations.
•When a Cartesian point (x, y) is converted to a homogeneous representation (xh, yh,
h), equations containing x and y, such as f(x, y) = 0, become homogeneous equations
in the three parameters xh, yh, and h.
•This just means that if each of the three parameters is replaced by any value v times
that parameter, the value v can be factored out of the equations.
,
h h
x y
x y
h h
 
Homogeneous Matrix Representation

































1
1
0
0
1
0
0
1
1
y
x
ty
tx
y
x
Homogeneous coordinate representation of 2D Translation
This translation operation can be written in the abbreviated form
'
( , )
x y
P T t t P
 
T(tx, ty) is the 3 by 3 translation matrix
 Homogeneous coordinate representation of 2D Rotation
 This translation operation can be written in the
abbreviated form
'
( )
P R P
q
 



















 













1
1
0
0
0
cos
sin
0
sin
cos
1
y
x
y
x
q
q
q
q
Homogeneous Matrix Representation
 Homogeneous coordinate representation of 2D
Scaling
 This scaling operation can be written in the
abbreviated form

































1
1
0
0
0
0
0
0
1
y
x
s
s
y
x
y
x
'
( , )
P S sx sy P
 
Homogeneous Matrix Representation
Composite transformation matrix
 We can set up a matrix for any sequence of
transformations as a composite transformation matrix
by calculating the matrix product of the individual
transformations.
 Forming products of transformation matrices is often
referred to as a concatenation, or composition of
matrices.
Composite transformation matrix
 Translations
If two successive translation vectors T(tx1, ty1) and T(tx1, ty1)
are applied to a coordinate position P (x, y) , the final
transformed location P/(x/, y/) is calculated as
P
t
t
T
t
t
T
P
P
t
t
T
t
t
T
P
y
x
y
x
y
x
y
x
)}.
,
(
).
,
(
{
}
).
,
(
).{
,
(
1
1
2
2
1
1
2
2





































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
Composite transformation matrix
 Rotation
Two successive rotations applied to point P(x, y) produce
the transformed position
P
R
P
R
R
R
P
R
R
P
R
R
P
).
(
Finally
)
(
)
(
).
(
But
)}.
(
).
(
{
}
).
(
).{
(
1
2
1
2
1
2
1
2
1
2
f
f
f
f
f
f
f
f
f
f








Composite transformation matrix
 Scaling
 Concatenating transformation matrices for two
successive scaling operations produces the following
composite scaling matrix
)
,
,
.
(
)
,
(
).
,
( 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 































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
General Two-Dimensional Pivot-Point
Rotation
 we can generate a 2D rotation about any other pivot
point (xr, yr) by performing the following sequence of
translate-rotate-translate operations
1. Translate the object so that the pivot-point position is
moved to the coordinate origin.
2. Rotate the object about the coordinate origin.
3. Translate the object so that the pivot point is returned to
its original position.
General Two-Dimensional Pivot-Point
Rotation
1 0 1 0 cos sin (1 cos ) sin
cos sin 0
0 1 sin cos 0 0 1 sin cos (1 cos ) sin
0 0 1
0 0 1 0 0 1 0 0 1
r r r r
r r r r
x x x y
y y y x
q q q q
q q
q q q q q q
   

     
 
     
     
     
 
     
 
 
     
The composite transformation matrix for this sequence
is obtained with the concatenation:
(xr,yr) (xr,yr) (xr,yr)
(xr,yr)
•Which can be expressed in the form
( , ) ( ) ( , ) ( , , )
r r r r r r
T x y R T x y R x y
q q
    
General Fixed-Point Scaling
Similarly, we can obtain the matrix representation of
General 2D Fixed-Point Scaling.
(xr,yr) (xr,yr) (xr,yr) (xr,yr)
Translate Scale Translate
General Fixed-Point Scaling















































1
0
0
)
1
(
0
)
1
(
0
1
0
0
1
0
0
1
1
0
0
0
0
0
0
1
0
0
1
0
0
1
y
f
y
x
f
x
f
f
x
f
f
s
y
s
s
x
s
y
x
s
s
y
x
y
       
y
x
f
f
f
f
y
x
f
f s
s
y
x
S
y
x
T
s
s
S
y
x
T ,
,
,
, ,
, 




1. Translate the object to so that the fixed point coincides
with the coordinate origin.
2. Scale the object with respect to the coordinate origin.
3. Use the inverse of the translation in step (1) to return
the object to its original position.
General 2D Scaling Directions
 We can scale an object in other directions by rotating the
object to align the desired scaling directions with the
coordinate axes before applying the scaling transformation.
 Suppose we want to apply scaling factors with values
specified by parameters s1 and s2 in the directions shown in
the following fig.
q
x
y s2
s1
General 2D Scaling Directions
To accomplish the scaling without changing the orientation of the object.
1. We first perform a rotation so that the directions for s1 and s2
coincide with the x and y axes, respectively.
2. Then the scaling transformation S(s1,s2) is applied.
3. An opposite rotation to return points to their original orientations.


















1
0
0
0
cos
sin
sin
cos
)
(
0
sin
cos
)
(
sin
cos
)
(
)
,
(
)
( 2
2
2
1
1
2
1
2
2
2
2
1
2
1
1
q
q
q
q
q
q
q
q
q
q s
s
s
s
s
s
s
s
R
s
s
S
R









 























1
0
0
0
cos
sin
0
sin
cos
1
0
0
0
0
0
0
1
0
0
0
cos
sin
0
sin
cos
2
1
f
f
f
f
f
f
f
f
s
s
General 2D Scaling Directions














1
0
0
0
45
cos
2
45
sin
1
sin
cos
)
1
2
(
0
45
sin
45
cos
)
1
2
(
45
sin
2
45
cos
1
0
2
0
2
0
0
0
2
0
2
q
q














1
0
0
0
cos
sin
sin
cos
)
(
0
sin
cos
)
(
sin
cos
2
2
2
1
1
2
1
2
2
2
2
1
q
q
q
q
q
q
q
q
s
s
s
s
s
s
s
s
x
y
(0,0)
(3/2,1/2)
(1/2,3/2) (2,2)
x
y
(0,0) (1,0)
(0,1) (1,1)
Scale
For example, we turn a unit square into a parallelogram by
stretching it along the diagonal from (0,0) to (1,1).











1
0
0
0
2
/
3
2
/
1
0
2
/
1
2
/
3



















1
1
.
2
/
3
2
/
1
2
/
1
2
/
3
2
2































1
1
0
.
1
0
0
0
2
/
3
2
/
1
0
2
/
1
2
/
3
1
2
/
3
2
/
1
Reflection
 A reflection is a transformation that produces a mirror
image of an object.
x-axis y-axis origin











1
0
0
0
1
0
0
0
1










1
0
0
0
1
0
0
0
1












1
0
0
0
1
0
0
0
1
x
y 1
3
2
1’
3’
2’
x
y
1
3
2
1’
3’ 2
x
y
3
1’
3’ 2
1
2
Reflection










1
0
0
0
0
1
0
1
0
Reflection about the diagonal
y = x
 Reflections about any line y = mx+c in the xy plane can be
accomplished with a combination of translate-rotate-reflect
transformations.
1. First translate the Line so that it passes through the origin.
2. Rotate the line onto one of the coordinate axes (x or y)
3. Reflect about that axis.
4. Restore the line to its original position with the inverse rotation and
translation transformations.
x
y
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 that had been caused to slide
over each other is called a shear.
 Two common shearing transformations are those that shift
coordinate x values and those that shift y values.
 An x-direction shear relative to the x axis is produced with
the transformation matrix
 The value of shx may any real number










1
0
0
0
1
0
0
1 x
sh
x = x + shx · y, y = y
x
y
x
y
(0,0) (1,0)
(1,1)
(0,1)
(0,0) (1,0)
(3,1)
(2,1)
Shear
 We can generate x-direction shears relative to other
reference lines with yref= - 1
 Now, coordinate positions are transformed as
x = x + shx · (y - yref), y = y









 

1
0
0
0
1
0
1 ref
x
x y
sh
sh
The following Fig. illustrates the
conversion of a square into a
parallelogram with shy=0.5 and
yref= 1
Shear
 Similarly an y-direction shear relative to the y axis is produced with
the transformation matrix
x = x, y = shy · x + y
 Similarly we can generate y-direction shears relative to the lines
xref= - 1
 Now, coordinate positions are transformed as
x = x + shy · (y - yref), y = y










1
0
0
0
1
0
0
1
y
sh











1
0
0
.
1
0
0
1
ref
y
y x
sh
sh
Shearing operations can be expressed as a
sequences of basic transformations. Such
as a series of rotation and scaling matrices
Coordinate Transformation
 Coordinate transformation is simply reverse to geometric
transformation. Following figures illustrate this
4
2
3
4
Original
Transformed
Coordinate Transformation




















y
x
y
x
f
f
f
f
cos
sin
sin
cos
'
'
Rotation
Coordinate Transformation

























y
x
s
s
y
x
y
x
1
0
0
1
'
'
4
4
Original
2
2
Transformed
Shear
Affine Transformation
 Translation, Scaling, Rotation, Shearing are all affine
transformation
 Affine transformation – transformed point P’ (x’,y’) is a
linear combination of the original point P (x,y), i.e.
x’ axx axy bx x
y’ = ayx ayy by y
1 0 0 1 1
• Affine transformations have the general properties
that parallel lines are transformed into parallel lines
and finite points map to finite points.
Affine Transformation
 Another affine transformation is the conversion of coordinate
descriptions from one reference system to another, which can
be described as a combination of translation and rotation
 An affine transformation involving only rotation, translation, and
reflection preserves angles and lengths, as well as parallel lines.
 For these three transformations, the lengths and angle between
two lines remains the same after the transformation.
Composing Transformation
 Composing Transformation – the process of applying
several transformation in succession to form one
overall transformation
 If we apply transform a point P using M1 matrix first,
and then transform using M2, and then M3, then we
have:
(M3 x (M2 x (M1 x P ))) = M3 x M2 x M1 x P
M
(pre-multiply)
Three-Dimensional Transformations
3D matrices
 Methods for geometric transformations in three
dimensions are extended from two-dimensional methods
by including considerations for the z coordinate.
 A three-dimensional position, expressed in
homogeneous coordinates, is represented as a four-
element column vector. Thus , each geometric
transformation operator is now 4 by 4 matrix.
3D Translation
Y
X
Z
(x, y, z)
(x, y , z )
T(tx, ty, tz)
TP = (x + tx, y + ty, z + tz)












1
0
0
0
1
0
0
0
1
0
0
0
1
z
y
x
t
t
t












1
z
y
x















1
0
0
0
1
0
0
0
1
0
0
0
1
z
y
x
t
t
t












1
z
y
x
Inverse Translation
3D Scaling
 SP = (sxx, syy, szz)












1
0
0
0
0
0
0
0
0
0
0
0
0
z
y
x
s
s
s












1
z
y
x
Inversion
General scaling
 Scaling with respect to a selected fixed position (xf, yf, zf)
can be represented with the following transformation
sequence:
1. Translate the fixed point to the origin.
2. Scale the object relative to the coordinate origin
3. Translate the fixed point back to its original position.
3D Rotation
3D Rotation
3D Rotation
General Rotation
 Rotating about an axis that is parallel to one of the coordinates
axes.
 Step1, Translate the object so that the rotation axis coincides
with the parallel coordinate axis.
 Step2, Perform the specified rotation about that axis.
 Step3, Translate the object so that rotation axis is moved back
to its original.
 A coordinate position P is transformed with the sequence
' 1
( )
x
P T R T P
q

   
General Rotation
 When an object is to be rotated about an axis that is not
parallel to one of the coordinate axes, we need to
perform some additional transformations.
1. Translate the object so that the rotation axis passes
through the coordinate origin
2. Rotate the object so that the axis of rotation coincides
with one of the coordinate axes.
3. Perform the specified rotation about that coordinate
axis.
4. Apply inverse rotations to bring the rotation axis back to
its original orientation.
5. Apply the inverse translation to bring the rotation axis
back to its original position.

3D Shear
 Shearing transformations can he
used to modify object shapes
 the following transformation produces a
z-axis shear












1
0
0
0
0
1
0
0
0
1
0
0
0
1
y
x
sh
sh












1
z
y
x
x
z
y
x
z
y

More Related Content

Similar to 2D and 3D transformations

2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformationsMohd Arif
 
2 d transformation
2 d transformation2 d transformation
2 d transformationAnkit Garg
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformationSelvakumar Gna
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)Timbal Mayank
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2SIMONTHOMAS S
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D2013901097
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2aravindangc
 
Bla b__________________la -2&3d -DD .ppt
Bla b__________________la -2&3d -DD .pptBla b__________________la -2&3d -DD .ppt
Bla b__________________la -2&3d -DD .pptkdemersal
 
2D Transformation
2D Transformation2D Transformation
2D TransformationShahDhruv21
 
seminar on 2D transformation
seminar on 2D transformationseminar on 2D transformation
seminar on 2D transformation9784
 
Lecture 6-1543909797
Lecture 6-1543909797Lecture 6-1543909797
Lecture 6-1543909797Canh Le
 
2 d translation
2 d translation2 d translation
2 d translationMani Kanth
 
09transformation3d
09transformation3d09transformation3d
09transformation3dKetan Jani
 

Similar to 2D and 3D transformations (20)

2 d geometric transformations
2 d geometric transformations2 d geometric transformations
2 d geometric transformations
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
 
Computer graphics basic transformation
Computer graphics basic transformationComputer graphics basic transformation
Computer graphics basic transformation
 
2D-transformation-1.pdf
2D-transformation-1.pdf2D-transformation-1.pdf
2D-transformation-1.pdf
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2
 
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 Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Bla b__________________la -2&3d -DD .ppt
Bla b__________________la -2&3d -DD .pptBla b__________________la -2&3d -DD .ppt
Bla b__________________la -2&3d -DD .ppt
 
transformation IT.ppt
transformation IT.ppttransformation IT.ppt
transformation IT.ppt
 
2D Transformation
2D Transformation2D Transformation
2D Transformation
 
2d transformations
2d transformations2d transformations
2d transformations
 
seminar on 2D transformation
seminar on 2D transformationseminar on 2D transformation
seminar on 2D transformation
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
 
2D Transformation.pdf
2D Transformation.pdf2D Transformation.pdf
2D Transformation.pdf
 
Lecture 6-1543909797
Lecture 6-1543909797Lecture 6-1543909797
Lecture 6-1543909797
 
2 d translation
2 d translation2 d translation
2 d translation
 
transformation 3d
transformation 3dtransformation 3d
transformation 3d
 
09transformation3d
09transformation3d09transformation3d
09transformation3d
 

Recently uploaded

EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIkoyaldeepu123
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
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
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
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
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
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
 
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
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
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
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixingviprabot1
 

Recently uploaded (20)

EduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AIEduAI - E learning Platform integrated with AI
EduAI - E learning Platform integrated with AI
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.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
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
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
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
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
 
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
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
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
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Effects of rheological properties on mixing
Effects of rheological properties on mixingEffects of rheological properties on mixing
Effects of rheological properties on mixing
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 

2D and 3D transformations

  • 1. Transformation 2D and 3D Dept. of Computer Science and Engineering Islamic University, Kushtia
  • 3. Transformations  Many applications need altering or manipulating displays
  • 4. Geometric Transformation Coordinate Transformation Object Transformed Coordinate Transformed Transformations There are two types of Transformation
  • 5. 2D Transformation  Given a 2D object, transformation is to change the object’s  Position (translation)  Orientation (rotation)  Size (scaling)  Shapes (shear)
  • 6. 2D Transformations How many way the object can be transformed? Three Basic Types of Transformation • Translation • Rotation • Scaling Another Transformations are • Reflection • Shear x y x y x y
  • 7. Translation  Re-position a point along a straight line  Given a point (x, y), and the translation distance (tx, ty) (x,y) (x’,y’) tx ty The new point: (x’, y’) x’ = x + tx y’ = y + ty or P’ = P + T                         y x t t T y x P y x P , ,                  y x t y t x y x
  • 8. Translation  How to translate an object with multiple vertices? Translate individual vertices
  • 9. 2D Rotation  Default rotation center: Origin (0,0) q q> 0 : Rotate counter clockwise q< 0 : Rotate clockwise q The rotation point/ Pivot point – The point at which the object is to be rotate (Positive Rotation) (Negative Rotation)
  • 10. Rotation (x,y) (x’,y’) q (x,y) -> Rotate about the origin by q (x’, y’) How to compute (x’, y’) ? f x = r cos (f) y = r sin (f) r x’ = r cos (f  q) y = r sin (f  q)
  • 11. Rotation (x,y) (x’,y’) q f r x = r cos (f) y = r sin (f) x’ = r cos (f  q) y = r sin (f  q) x’ = r cos (f  q) = r cos(f) cos(q) – r sin(f) sin(q) = x cos(q)– y sin(q) y’ = r sin (f  q) = r sin(f) cos(q) + r cos(f)sin(q) = y cos(q) + x sin(q)
  • 12. Rotation (x,y) (x’,y’) q f r x’ = x cos(q) – y sin(q) y’ = y cos(q) + x sin(q) Matrix form? x’ cos(q) -sin(q) x y’ sin(q) cos(q) y = P/ = R(f). P
  • 13. Rotation  How to rotate an object with multiple vertices? Rotate individual Vertices q
  • 14. Scaling Scale: Alter the size of an object by a scaling factor (Sx, Sy), i.e. x’ = x . Sx y’ = y . Sy (1,1) (2,2) Sx = 2, Sy = 2 (2,2) (4,4)                    y x s s y x y x 0 0 ' ' Fixed point – The point that used to control the location of a scaled object P/ = S. P
  • 15. 2D Scaling (1,1) (2,2) Sx = 2, Sy = 2 (2,2) (4,4)  Not only the object size is changed, it also moved!!  Usually this is an undesirable effect  We will discuss later (soon) how to fix it
  • 16. Put it all together                  y x t y t x y x Translation: Rotation: Scaling:                    y x s s y x y x 0 0 ' ' P=T + P P=S  P P=R  P                     y x y x f f f f cos sin sin cos ' '
  • 17. Matrix Representation and Homogeneous Coordinates  Many graphics applications involve sequences of geometric transformations. Example  In animation, an object to be translated and rotated at each increment of the motion.  In design and picture construction applications, translations, rotations, and scalings are used to fit the picture components into their proper positions.  Rotation and Scaling matrix are 2 by 2 and point P is multiplied with matrix R or S  Translation matrix is 2 by 1 and it is add with point P  The multiplicative and translational terms for two-dimensional geometric transformations into a single Matrix representation by expanding the 2 by 2 matrix representations to 3 by 3 matrices.  This allows us to express all transformation equations as matrix multiplications
  • 18. Homogeneous Coordinates Any 2D transformation can be described uniquely by a 3x3 matrix, if the Cartesian coordinates (x, y) is represented by the homogeneous coordinate triple (xh, yh, h), where h can be any real value ≠ 0, for simplicity h=1 is used here •The term homogeneous coordinates is used in mathematics to refer to the effect of this representation on Cartesian equations. •When a Cartesian point (x, y) is converted to a homogeneous representation (xh, yh, h), equations containing x and y, such as f(x, y) = 0, become homogeneous equations in the three parameters xh, yh, and h. •This just means that if each of the three parameters is replaced by any value v times that parameter, the value v can be factored out of the equations. , h h x y x y h h  
  • 19. Homogeneous Matrix Representation                                  1 1 0 0 1 0 0 1 1 y x ty tx y x Homogeneous coordinate representation of 2D Translation This translation operation can be written in the abbreviated form ' ( , ) x y P T t t P   T(tx, ty) is the 3 by 3 translation matrix
  • 20.  Homogeneous coordinate representation of 2D Rotation  This translation operation can be written in the abbreviated form ' ( ) P R P q                                     1 1 0 0 0 cos sin 0 sin cos 1 y x y x q q q q Homogeneous Matrix Representation
  • 21.  Homogeneous coordinate representation of 2D Scaling  This scaling operation can be written in the abbreviated form                                  1 1 0 0 0 0 0 0 1 y x s s y x y x ' ( , ) P S sx sy P   Homogeneous Matrix Representation
  • 22. Composite transformation matrix  We can set up a matrix for any sequence of transformations as a composite transformation matrix by calculating the matrix product of the individual transformations.  Forming products of transformation matrices is often referred to as a concatenation, or composition of matrices.
  • 23. Composite transformation matrix  Translations If two successive translation vectors T(tx1, ty1) and T(tx1, ty1) are applied to a coordinate position P (x, y) , the final transformed location P/(x/, y/) is calculated as P t t T t t T P P t t T t t T P y x y x y x y x )}. , ( ). , ( { } ). , ( ).{ , ( 1 1 2 2 1 1 2 2                                      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
  • 24. Composite transformation matrix  Rotation Two successive rotations applied to point P(x, y) produce the transformed position P R P R R R P R R P R R P ). ( Finally ) ( ) ( ). ( But )}. ( ). ( { } ). ( ).{ ( 1 2 1 2 1 2 1 2 1 2 f f f f f f f f f f        
  • 25. Composite transformation matrix  Scaling  Concatenating transformation matrices for two successive scaling operations produces the following composite scaling matrix ) , , . ( ) , ( ). , ( 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                                 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
  • 26. General Two-Dimensional Pivot-Point Rotation  we can generate a 2D rotation about any other pivot point (xr, yr) by performing the following sequence of translate-rotate-translate operations 1. Translate the object so that the pivot-point position is moved to the coordinate origin. 2. Rotate the object about the coordinate origin. 3. Translate the object so that the pivot point is returned to its original position.
  • 27. General Two-Dimensional Pivot-Point Rotation 1 0 1 0 cos sin (1 cos ) sin cos sin 0 0 1 sin cos 0 0 1 sin cos (1 cos ) sin 0 0 1 0 0 1 0 0 1 0 0 1 r r r r r r r r x x x y y y y x q q q q q q q q q q q q                                                  The composite transformation matrix for this sequence is obtained with the concatenation: (xr,yr) (xr,yr) (xr,yr) (xr,yr) •Which can be expressed in the form ( , ) ( ) ( , ) ( , , ) r r r r r r T x y R T x y R x y q q     
  • 28. General Fixed-Point Scaling Similarly, we can obtain the matrix representation of General 2D Fixed-Point Scaling. (xr,yr) (xr,yr) (xr,yr) (xr,yr) Translate Scale Translate
  • 29. General Fixed-Point Scaling                                                1 0 0 ) 1 ( 0 ) 1 ( 0 1 0 0 1 0 0 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 y f y x f x f f x f f s y s s x s y x s s y x y         y x f f f f y x f f s s y x S y x T s s S y x T , , , , , ,      1. Translate the object to so that the fixed point coincides with the coordinate origin. 2. Scale the object with respect to the coordinate origin. 3. Use the inverse of the translation in step (1) to return the object to its original position.
  • 30. General 2D Scaling Directions  We can scale an object in other directions by rotating the object to align the desired scaling directions with the coordinate axes before applying the scaling transformation.  Suppose we want to apply scaling factors with values specified by parameters s1 and s2 in the directions shown in the following fig. q x y s2 s1
  • 31. General 2D Scaling Directions To accomplish the scaling without changing the orientation of the object. 1. We first perform a rotation so that the directions for s1 and s2 coincide with the x and y axes, respectively. 2. Then the scaling transformation S(s1,s2) is applied. 3. An opposite rotation to return points to their original orientations.                   1 0 0 0 cos sin sin cos ) ( 0 sin cos ) ( sin cos ) ( ) , ( ) ( 2 2 2 1 1 2 1 2 2 2 2 1 2 1 1 q q q q q q q q q q s s s s s s s s R s s S R                                   1 0 0 0 cos sin 0 sin cos 1 0 0 0 0 0 0 1 0 0 0 cos sin 0 sin cos 2 1 f f f f f f f f s s
  • 32. General 2D Scaling Directions               1 0 0 0 45 cos 2 45 sin 1 sin cos ) 1 2 ( 0 45 sin 45 cos ) 1 2 ( 45 sin 2 45 cos 1 0 2 0 2 0 0 0 2 0 2 q q               1 0 0 0 cos sin sin cos ) ( 0 sin cos ) ( sin cos 2 2 2 1 1 2 1 2 2 2 2 1 q q q q q q q q s s s s s s s s x y (0,0) (3/2,1/2) (1/2,3/2) (2,2) x y (0,0) (1,0) (0,1) (1,1) Scale For example, we turn a unit square into a parallelogram by stretching it along the diagonal from (0,0) to (1,1).            1 0 0 0 2 / 3 2 / 1 0 2 / 1 2 / 3                    1 1 . 2 / 3 2 / 1 2 / 1 2 / 3 2 2                                1 1 0 . 1 0 0 0 2 / 3 2 / 1 0 2 / 1 2 / 3 1 2 / 3 2 / 1
  • 33. Reflection  A reflection is a transformation that produces a mirror image of an object. x-axis y-axis origin            1 0 0 0 1 0 0 0 1           1 0 0 0 1 0 0 0 1             1 0 0 0 1 0 0 0 1 x y 1 3 2 1’ 3’ 2’ x y 1 3 2 1’ 3’ 2 x y 3 1’ 3’ 2 1 2
  • 34. Reflection           1 0 0 0 0 1 0 1 0 Reflection about the diagonal y = x  Reflections about any line y = mx+c in the xy plane can be accomplished with a combination of translate-rotate-reflect transformations. 1. First translate the Line so that it passes through the origin. 2. Rotate the line onto one of the coordinate axes (x or y) 3. Reflect about that axis. 4. Restore the line to its original position with the inverse rotation and translation transformations. x y
  • 35. 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 that had been caused to slide over each other is called a shear.  Two common shearing transformations are those that shift coordinate x values and those that shift y values.  An x-direction shear relative to the x axis is produced with the transformation matrix  The value of shx may any real number           1 0 0 0 1 0 0 1 x sh x = x + shx · y, y = y x y x y (0,0) (1,0) (1,1) (0,1) (0,0) (1,0) (3,1) (2,1)
  • 36. Shear  We can generate x-direction shears relative to other reference lines with yref= - 1  Now, coordinate positions are transformed as x = x + shx · (y - yref), y = y             1 0 0 0 1 0 1 ref x x y sh sh The following Fig. illustrates the conversion of a square into a parallelogram with shy=0.5 and yref= 1
  • 37. Shear  Similarly an y-direction shear relative to the y axis is produced with the transformation matrix x = x, y = shy · x + y  Similarly we can generate y-direction shears relative to the lines xref= - 1  Now, coordinate positions are transformed as x = x + shy · (y - yref), y = y           1 0 0 0 1 0 0 1 y sh            1 0 0 . 1 0 0 1 ref y y x sh sh Shearing operations can be expressed as a sequences of basic transformations. Such as a series of rotation and scaling matrices
  • 38. Coordinate Transformation  Coordinate transformation is simply reverse to geometric transformation. Following figures illustrate this 4 2 3 4 Original Transformed
  • 41. Affine Transformation  Translation, Scaling, Rotation, Shearing are all affine transformation  Affine transformation – transformed point P’ (x’,y’) is a linear combination of the original point P (x,y), i.e. x’ axx axy bx x y’ = ayx ayy by y 1 0 0 1 1 • Affine transformations have the general properties that parallel lines are transformed into parallel lines and finite points map to finite points.
  • 42. Affine Transformation  Another affine transformation is the conversion of coordinate descriptions from one reference system to another, which can be described as a combination of translation and rotation  An affine transformation involving only rotation, translation, and reflection preserves angles and lengths, as well as parallel lines.  For these three transformations, the lengths and angle between two lines remains the same after the transformation.
  • 43. Composing Transformation  Composing Transformation – the process of applying several transformation in succession to form one overall transformation  If we apply transform a point P using M1 matrix first, and then transform using M2, and then M3, then we have: (M3 x (M2 x (M1 x P ))) = M3 x M2 x M1 x P M (pre-multiply)
  • 45. 3D matrices  Methods for geometric transformations in three dimensions are extended from two-dimensional methods by including considerations for the z coordinate.  A three-dimensional position, expressed in homogeneous coordinates, is represented as a four- element column vector. Thus , each geometric transformation operator is now 4 by 4 matrix.
  • 46. 3D Translation Y X Z (x, y, z) (x, y , z ) T(tx, ty, tz) TP = (x + tx, y + ty, z + tz)             1 0 0 0 1 0 0 0 1 0 0 0 1 z y x t t t             1 z y x                1 0 0 0 1 0 0 0 1 0 0 0 1 z y x t t t             1 z y x Inverse Translation
  • 47. 3D Scaling  SP = (sxx, syy, szz)             1 0 0 0 0 0 0 0 0 0 0 0 0 z y x s s s             1 z y x Inversion
  • 48. General scaling  Scaling with respect to a selected fixed position (xf, yf, zf) can be represented with the following transformation sequence: 1. Translate the fixed point to the origin. 2. Scale the object relative to the coordinate origin 3. Translate the fixed point back to its original position.
  • 52. General Rotation  Rotating about an axis that is parallel to one of the coordinates axes.  Step1, Translate the object so that the rotation axis coincides with the parallel coordinate axis.  Step2, Perform the specified rotation about that axis.  Step3, Translate the object so that rotation axis is moved back to its original.  A coordinate position P is transformed with the sequence ' 1 ( ) x P T R T P q     
  • 53. General Rotation  When an object is to be rotated about an axis that is not parallel to one of the coordinate axes, we need to perform some additional transformations. 1. Translate the object so that the rotation axis passes through the coordinate origin 2. Rotate the object so that the axis of rotation coincides with one of the coordinate axes. 3. Perform the specified rotation about that coordinate axis. 4. Apply inverse rotations to bring the rotation axis back to its original orientation. 5. Apply the inverse translation to bring the rotation axis back to its original position.
  • 54.
  • 55.
  • 56. 3D Shear  Shearing transformations can he used to modify object shapes  the following transformation produces a z-axis shear             1 0 0 0 0 1 0 0 0 1 0 0 0 1 y x sh sh             1 z y x x z y x z y