Presented By
Aditi Patni
Bachelors of Computer Application-Second Year
Dezyne E’Cole College, Ajmer
COMPUTER GRAPHICS
Project report on
2-D Transformations
Submitted To
Dezyne E’Cole College
Towards
The Partial Fulfilment
Of 2019 Year, Bachelor of Computer Application
By
Aditi Patni
Dezyne E’Cole College
106/10, Civil Line, Ajmer
www.dezyneecole.com
Acknowledgement
I Am Aditi Patni, student of Bachelor of Computer Application,
Dezyne E’Cole College. I would like to express my gratitude to
each and every person who has contributed in encouraging me
and helping me to coordinate my project.
I also thank Dezyne E’Cole College who provided insight and
expertise that greatly assisted the project. A special thanks to my
teachers, parents and colleagues who have supported me at every
step. Not to forget, the Almighty who blessed me with good
health because of which I worked more efficiently and better.
CONTENTS
 What is 2-D Transformations?
 Basic Transformations
 Translation
 Rotation
 Scaling
 Derived Transformations
 Reflection
 Shearing
2-D TRANSFORMATIONS
 Changes in the orientation, shape, size or position of an object,
such that the coordinate values of the object changes, is known
as 2-D Transformation.
 There are two types of transformations:
o Basic Transformation
o Derived Transformation
 The three basic transformations are:
o Translation
o Rotation
o Scaling
 From these three basic transformations two more transformation
has been derived. They are known as Derived Transformation.
 The derived transformation are:
o Reflection
o Shearing
Basic Transformations:
Translation:
 Translation can be defined as repositioning an object on a
straight path from one coordinate location to another coordinate
location.
 Translation is always considered on a straight path.
 The total distance by which an object is translated is known as
translation distance.
 There are two methods to perform translation:
1. Classic Method:
X’=X+Tx
Y’=Y+Ty
Tx= Translation in x direction
Ty= Translation in y direction
2. Modern Method:
Q’= T*Q
Q’= New Coordinates
T= Translation Distance
Q= Original Coordinates
1 0 Tx
0 1 Ty
0 0 1
Example:
Tx=3, Ty=3
Y
X’ 0 1 2 3 4 5 6 7 8 X
Y’
By Classic Method:
A: X’= 2+3= 5
Y’= 1+3= 4 (5, 4)
B: X’= 4+3= 7
Y’= 1+3= 4 (7, 4)
C: X’= 3+3= 6
Y’= 3+3= 6 (6, 6)
1
5
4
3
2
6
8
7
By Modern Method:
Q’= T*Q
Q’= 1 0 Tx 2 4 3
0 1 Ty 1 1 3
0 0 1 1 1 1
Q’= 1 0 3 2 4 3
0 1 3 1 1 3
0 0 1 1 1 1
Q’= 2+0+3 4+0+3 3+0+3
0+1+3 0+1+3 0+3+3
0+0+1 0+0+1 0+0+1
Q’= 5 7 6
4 4 6 (Answer)
1 1 1
Rotation:
 Rotation can be defined as repositioning an object on a circular
path from one angle to another.
 The fixed point is called the pivot point.
 We can rotate an object with five different angles and there is a
table with all these values:
Angle 0 degree 30 degree 45 degree 60 degree 90 degree
Sin 0 0.5 0.70 0.87 1
Cos 1 0.87 0.70 0.5 0
 The predefined matrix of rotation is:
Cos -Sin 0
Sin Cos 0
0 0 1
Example:
Rotation at 90 degree.
P’= R*P
P’= New Coordinates
R= Rotational Matrix
P= Original Coordinates
Y
5
4
3
2
1
X’ -4 -3 -2 -1 0 1 2 3 4 X
Y’
P’= Cos -Sin 0 1 4 1 4
Sin Cos 0 1 1 4 4
0 0 1 1 1 1 1
P’= 0 -1 0 1 4 1 4
1 0 0 1 1 4 4
0 0 1 1 1 1 1
P’= 0-1+0 0-1+0 0-4+0 0-4+0
1+0+0 4+0+0 1+0+0 4+0+0
0+0+1 0+0+1 0+0+1 0+0+1
P’= -1 -4 -1 -4
1 4 1 4 (Answer)
1 1 1 1
Scaling:
 A scaling transformation changes the size of an object. The size
may increase or decrease depending on the coordinate values.
 Sx and Sy are scaling factors.
 There are two methods to perform scaling:
1. Classic Method:
X’= X*Sx
Y’= Y*Sy
Sx= Scaling in X direction
Sy= Scaling in Y direction
2. Modern Method:
P’= S*P
P’= New Coordinates
S= Scaling Matrix
P= Original Coordinates
Sx 0 0
0 Sy 0
0 0 1
Example:
Sx=2, Sy=2
Y
X’ 0 1 2 3 4 5 6 7 8 X
Y’
1. Classic Method:
A: 2*2=4
1*2=2 (4, 2)
1
5
4
3
2
6
8
7
B: 4*2=8
1*2=2 (8, 2)
C: 3*2=6
3*2=6 (6, 6)
2. Modern Method:
P’= S*P
P’= Sx 0 0 2 4 3
0 Sy 0 1 1 3
0 0 1 1 1 1
P’= 2 0 0 2 4 3
0 2 0 1 1 3
0 0 1 1 1 1
P’= 4+0+0 8+0+0 6+0+0
0+2+0 0+2+0 0+6+0
0+0+1 0+0+1 0+0+1
P’= 4 8 6
2 2 6 (Answer)
1 1 1
Derived Transformations:
Reflection:
 In reflection we get the mirror image of an object.
 In this transformation, the size or shape of the object do not
change.
 To perform reflection we need a fixed line known as Reflection
Axis.
 As reflection has been derived from translation and rotation
therefore, it is known as derived transformation.
 There are four types of reflection:
o Reflection about x axis
o Reflection about Y axis
o Reflection when the reflection axis passes through
origin
o Reflection with respect to a diagonal line.
1. Reflection about X axis:
 In this the object is reflected with respect to X axis.
 The value of X remains same whereas the value of Y
becomes negative.
 The predefined matrix is:
1 0 0
0 -1 0
0 0 1
P’=R*P
P’= New Coordinates
R= Reflection Matrix
P= Original Coordinates
Example:
Y
5
4
3
2
1
X’ 0 1 2 3 4 5 6 X
-1
-2
-3
-4
-5
Y’
P’= 1 0 0 2 6 4
0 -1 0 1 1 4
0 0 1 1 1 1
P’= 2+0+0 6+0+0 4+0+0
0-1+0 0-1+0 0-4+0
0+0+1 0+0+1 0+0+1
P’= 2 6 4
-1 -1 -4 (Answer)
1 1 1
2. Reflection about Y axis:
 In this the object is reflected with respect of Y axis.
 The value of X becomes negative whereas the value of Y
remains same.
 The predefined matrix is:
-1 0 0
0 1 0
0 0 1
Example:
P’=S*P
P’= -1 0 0 2 6 4
0 1 0 1 1 4
0 0 1 1 1 1
P’= -2+0+0 -6+0+0 -4+0+0
0+1+0 0+1+0 0+4+0
0+0+1 0+0+1 0+0+1
P’= -2 -6 -4
1 1 4 (Answer)
1 1 1
Y
5
4
3
2
1
X’ -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 X
Y’
3. Reflection when the reflection axis passes through the origin:
 In this, the object is rotated around the reflection axis by 180*.
 The value of both X and Y coordinates becomes negative.
 The predefined matrix is:
-1 0 0
0 -1 0
0 0 1
P’=R*P
P’= New Coordinates
R= Reflection Matrix
P= Original Coordinates
Example:
Y
5
4
3
2
1
X’ -5 -4 -3 -2 -1 0 1 2 3 4 5 X
-1
-2
-3
-4
-5
Y’
P’=R*P
P’= -1 0 0 1 5 3
0 -1 0 1 1 4
0 0 1 1 1 1
P’= -1+0+0 -5+0+0 -3+0+0
0-1+0 0-1+0 0-4+0
0+0+1 0+0+1 0+0+1
P’= -1 -5 -3
-1 -1 -4
1 1 1
4. Reflection with respect to a diagonal line:
 In this, the reflection axis and the object are rotated by 45* such
that the reflection axis coincides with X axis.
 The values of X and y coordinates gets interchanged.
 The predefined matrix is:
0 1 0
1 0 0
0 0 1
P’=R*P
P’= New Coordinates
R= Reflection Matrix
P= Original Coordinates
Example:
Y
5
4
3
2
1
X’ 0 1 2 3 4 5 6 X
Y’
P’= R*P
P’= 0 1 0 3 5 4
1 0 0 1 1 3
0 0 1 1 1 1
P’= 0+1+0 0+1+0 0+3+0
3+0+0 5+0+0 4+0+0
0+0+1 0+0+1 0+0+1
P’= 1 1 3
3 5 4 (Answer)
1 1 1
Shearing:
 Shearing is a transformation in which the shape of the object
changes. During shearing we assume that object is made up of
many layers. In shearing the top layer is shifted and the bottom
layer remains fixed.
 There are two types of shearing:
o Shearing in X direction
o Shearing in Y direction
1. Shearing in X direction:
 In such shearing the coordinates of the object are shifted
horizontally along the X axis.
 The distance by which the coordinates will be shifted is store
in a variable shx also called shearing parameter.
 The predefined matrix is:
P’= S*P
1 shx 0
0 1 0
0 0 1
P’= New Coordinates
S= Shearing Matrix
P= Original Coordinates
Example:
Shx=2
Y
5
4
3
2
1
X’ 0 1 2 3 4 5 6 7 8 9 10 X
Y’
P’= 1 shx 0 1 4 4 1
0 1 0 1 1 3 3
0 0 1 1 1 1 1
P’= 1 shx 0 1 4 4 1
0 1 0 1 1 3 3
0 0 1 1 1 1 1
P’= 1 2 0 1 4 4 1
0 1 0 1 1 3 3
0 0 1 1 1 1 1
P’= 1+2+0 4+2+0 4+6+0 1+6+0
0+1+0 0+1+0 0+3+0 0+3+0
0+0+1 0+0+1 0+0+1 0+0+1
P’= 3 6 10 7
1 1 3 3 (Answer)
1 1 1 1
2. Shearing in Y direction:
 In such shearing the coordinates of the object are shifted
vertically about y axis.
 The distance by which the coordinates are shifted is stored in a
variable shy also called shearing parameter.
 The predefined matrix is:
1 0 0
shy 1 0
0 0 1
P’= S*P
P’= New Coordinates
S= Shearing Matrix
P= Original Coordinates
Example: Y
11
10
9
8
7
6
5
4
3
2
1
X’ 0 1 2 3 4 5 6 7 8 X
Y’
P’= 1 0 0 1 4 4 1
shy 1 0 1 1 3 3
0 0 1 1 1 1 1
P’= 1 0 0 1 4 4 1
2 1 0 1 1 3 3
0 0 1 1 1 1 1
P’= 1+0+0 4+0+0 4+0+0 1+0+0
2+1+0 8+1+0 8+3+0 2+3+0
0+0+1 0+0+1 0+0+1 0+0+1
P’= 1 4 4 1
3 9 11 5 (Answer)
1 1 1 1
Thank You
Presented By
Aditi Patni
Bachelors of Computer Applications
Dezyne E’Cole College
www.dezyneecole.com

2D Transformations(Computer Graphics)

  • 1.
    Presented By Aditi Patni Bachelorsof Computer Application-Second Year Dezyne E’Cole College, Ajmer COMPUTER GRAPHICS
  • 2.
    Project report on 2-DTransformations Submitted To Dezyne E’Cole College Towards The Partial Fulfilment Of 2019 Year, Bachelor of Computer Application By Aditi Patni Dezyne E’Cole College 106/10, Civil Line, Ajmer www.dezyneecole.com
  • 3.
    Acknowledgement I Am AditiPatni, student of Bachelor of Computer Application, Dezyne E’Cole College. I would like to express my gratitude to each and every person who has contributed in encouraging me and helping me to coordinate my project. I also thank Dezyne E’Cole College who provided insight and expertise that greatly assisted the project. A special thanks to my teachers, parents and colleagues who have supported me at every step. Not to forget, the Almighty who blessed me with good health because of which I worked more efficiently and better.
  • 4.
    CONTENTS  What is2-D Transformations?  Basic Transformations  Translation  Rotation  Scaling  Derived Transformations  Reflection  Shearing
  • 5.
    2-D TRANSFORMATIONS  Changesin the orientation, shape, size or position of an object, such that the coordinate values of the object changes, is known as 2-D Transformation.  There are two types of transformations: o Basic Transformation o Derived Transformation  The three basic transformations are: o Translation o Rotation o Scaling  From these three basic transformations two more transformation has been derived. They are known as Derived Transformation.  The derived transformation are: o Reflection o Shearing
  • 6.
    Basic Transformations: Translation:  Translationcan be defined as repositioning an object on a straight path from one coordinate location to another coordinate location.  Translation is always considered on a straight path.  The total distance by which an object is translated is known as translation distance.  There are two methods to perform translation: 1. Classic Method: X’=X+Tx Y’=Y+Ty Tx= Translation in x direction Ty= Translation in y direction 2. Modern Method: Q’= T*Q Q’= New Coordinates T= Translation Distance Q= Original Coordinates
  • 7.
    1 0 Tx 01 Ty 0 0 1 Example: Tx=3, Ty=3 Y X’ 0 1 2 3 4 5 6 7 8 X Y’ By Classic Method: A: X’= 2+3= 5 Y’= 1+3= 4 (5, 4) B: X’= 4+3= 7 Y’= 1+3= 4 (7, 4) C: X’= 3+3= 6 Y’= 3+3= 6 (6, 6) 1 5 4 3 2 6 8 7
  • 8.
    By Modern Method: Q’=T*Q Q’= 1 0 Tx 2 4 3 0 1 Ty 1 1 3 0 0 1 1 1 1 Q’= 1 0 3 2 4 3 0 1 3 1 1 3 0 0 1 1 1 1 Q’= 2+0+3 4+0+3 3+0+3 0+1+3 0+1+3 0+3+3 0+0+1 0+0+1 0+0+1 Q’= 5 7 6 4 4 6 (Answer) 1 1 1
  • 9.
    Rotation:  Rotation canbe defined as repositioning an object on a circular path from one angle to another.  The fixed point is called the pivot point.  We can rotate an object with five different angles and there is a table with all these values: Angle 0 degree 30 degree 45 degree 60 degree 90 degree Sin 0 0.5 0.70 0.87 1 Cos 1 0.87 0.70 0.5 0  The predefined matrix of rotation is: Cos -Sin 0 Sin Cos 0 0 0 1 Example: Rotation at 90 degree. P’= R*P P’= New Coordinates R= Rotational Matrix P= Original Coordinates
  • 10.
    Y 5 4 3 2 1 X’ -4 -3-2 -1 0 1 2 3 4 X Y’ P’= Cos -Sin 0 1 4 1 4 Sin Cos 0 1 1 4 4 0 0 1 1 1 1 1 P’= 0 -1 0 1 4 1 4 1 0 0 1 1 4 4 0 0 1 1 1 1 1 P’= 0-1+0 0-1+0 0-4+0 0-4+0 1+0+0 4+0+0 1+0+0 4+0+0 0+0+1 0+0+1 0+0+1 0+0+1
  • 11.
    P’= -1 -4-1 -4 1 4 1 4 (Answer) 1 1 1 1 Scaling:  A scaling transformation changes the size of an object. The size may increase or decrease depending on the coordinate values.  Sx and Sy are scaling factors.  There are two methods to perform scaling: 1. Classic Method: X’= X*Sx Y’= Y*Sy Sx= Scaling in X direction Sy= Scaling in Y direction 2. Modern Method: P’= S*P P’= New Coordinates S= Scaling Matrix P= Original Coordinates
  • 12.
    Sx 0 0 0Sy 0 0 0 1 Example: Sx=2, Sy=2 Y X’ 0 1 2 3 4 5 6 7 8 X Y’ 1. Classic Method: A: 2*2=4 1*2=2 (4, 2) 1 5 4 3 2 6 8 7
  • 13.
    B: 4*2=8 1*2=2 (8,2) C: 3*2=6 3*2=6 (6, 6) 2. Modern Method: P’= S*P P’= Sx 0 0 2 4 3 0 Sy 0 1 1 3 0 0 1 1 1 1 P’= 2 0 0 2 4 3 0 2 0 1 1 3 0 0 1 1 1 1 P’= 4+0+0 8+0+0 6+0+0 0+2+0 0+2+0 0+6+0 0+0+1 0+0+1 0+0+1 P’= 4 8 6 2 2 6 (Answer) 1 1 1
  • 14.
    Derived Transformations: Reflection:  Inreflection we get the mirror image of an object.  In this transformation, the size or shape of the object do not change.  To perform reflection we need a fixed line known as Reflection Axis.  As reflection has been derived from translation and rotation therefore, it is known as derived transformation.  There are four types of reflection: o Reflection about x axis o Reflection about Y axis o Reflection when the reflection axis passes through origin o Reflection with respect to a diagonal line. 1. Reflection about X axis:  In this the object is reflected with respect to X axis.  The value of X remains same whereas the value of Y becomes negative.  The predefined matrix is: 1 0 0 0 -1 0 0 0 1
  • 15.
    P’=R*P P’= New Coordinates R=Reflection Matrix P= Original Coordinates Example: Y 5 4 3 2 1 X’ 0 1 2 3 4 5 6 X -1 -2 -3 -4 -5 Y’ P’= 1 0 0 2 6 4 0 -1 0 1 1 4 0 0 1 1 1 1
  • 16.
    P’= 2+0+0 6+0+04+0+0 0-1+0 0-1+0 0-4+0 0+0+1 0+0+1 0+0+1 P’= 2 6 4 -1 -1 -4 (Answer) 1 1 1 2. Reflection about Y axis:  In this the object is reflected with respect of Y axis.  The value of X becomes negative whereas the value of Y remains same.  The predefined matrix is: -1 0 0 0 1 0 0 0 1 Example: P’=S*P P’= -1 0 0 2 6 4 0 1 0 1 1 4 0 0 1 1 1 1
  • 17.
    P’= -2+0+0 -6+0+0-4+0+0 0+1+0 0+1+0 0+4+0 0+0+1 0+0+1 0+0+1 P’= -2 -6 -4 1 1 4 (Answer) 1 1 1 Y 5 4 3 2 1 X’ -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 X Y’ 3. Reflection when the reflection axis passes through the origin:  In this, the object is rotated around the reflection axis by 180*.  The value of both X and Y coordinates becomes negative.  The predefined matrix is:
  • 18.
    -1 0 0 0-1 0 0 0 1 P’=R*P P’= New Coordinates R= Reflection Matrix P= Original Coordinates Example: Y 5 4 3 2 1 X’ -5 -4 -3 -2 -1 0 1 2 3 4 5 X -1 -2 -3 -4 -5 Y’
  • 19.
    P’=R*P P’= -1 00 1 5 3 0 -1 0 1 1 4 0 0 1 1 1 1 P’= -1+0+0 -5+0+0 -3+0+0 0-1+0 0-1+0 0-4+0 0+0+1 0+0+1 0+0+1 P’= -1 -5 -3 -1 -1 -4 1 1 1 4. Reflection with respect to a diagonal line:  In this, the reflection axis and the object are rotated by 45* such that the reflection axis coincides with X axis.  The values of X and y coordinates gets interchanged.  The predefined matrix is: 0 1 0 1 0 0 0 0 1
  • 20.
    P’=R*P P’= New Coordinates R=Reflection Matrix P= Original Coordinates Example: Y 5 4 3 2 1 X’ 0 1 2 3 4 5 6 X Y’ P’= R*P P’= 0 1 0 3 5 4 1 0 0 1 1 3 0 0 1 1 1 1
  • 21.
    P’= 0+1+0 0+1+00+3+0 3+0+0 5+0+0 4+0+0 0+0+1 0+0+1 0+0+1 P’= 1 1 3 3 5 4 (Answer) 1 1 1 Shearing:  Shearing is a transformation in which the shape of the object changes. During shearing we assume that object is made up of many layers. In shearing the top layer is shifted and the bottom layer remains fixed.  There are two types of shearing: o Shearing in X direction o Shearing in Y direction 1. Shearing in X direction:  In such shearing the coordinates of the object are shifted horizontally along the X axis.  The distance by which the coordinates will be shifted is store in a variable shx also called shearing parameter.  The predefined matrix is: P’= S*P
  • 22.
    1 shx 0 01 0 0 0 1 P’= New Coordinates S= Shearing Matrix P= Original Coordinates Example: Shx=2 Y 5 4 3 2 1 X’ 0 1 2 3 4 5 6 7 8 9 10 X Y’ P’= 1 shx 0 1 4 4 1 0 1 0 1 1 3 3 0 0 1 1 1 1 1
  • 23.
    P’= 1 shx0 1 4 4 1 0 1 0 1 1 3 3 0 0 1 1 1 1 1 P’= 1 2 0 1 4 4 1 0 1 0 1 1 3 3 0 0 1 1 1 1 1 P’= 1+2+0 4+2+0 4+6+0 1+6+0 0+1+0 0+1+0 0+3+0 0+3+0 0+0+1 0+0+1 0+0+1 0+0+1 P’= 3 6 10 7 1 1 3 3 (Answer) 1 1 1 1 2. Shearing in Y direction:  In such shearing the coordinates of the object are shifted vertically about y axis.  The distance by which the coordinates are shifted is stored in a variable shy also called shearing parameter.  The predefined matrix is:
  • 24.
    1 0 0 shy1 0 0 0 1 P’= S*P P’= New Coordinates S= Shearing Matrix P= Original Coordinates Example: Y 11 10 9 8 7 6 5 4 3 2 1 X’ 0 1 2 3 4 5 6 7 8 X Y’
  • 25.
    P’= 1 00 1 4 4 1 shy 1 0 1 1 3 3 0 0 1 1 1 1 1 P’= 1 0 0 1 4 4 1 2 1 0 1 1 3 3 0 0 1 1 1 1 1 P’= 1+0+0 4+0+0 4+0+0 1+0+0 2+1+0 8+1+0 8+3+0 2+3+0 0+0+1 0+0+1 0+0+1 0+0+1 P’= 1 4 4 1 3 9 11 5 (Answer) 1 1 1 1
  • 26.
    Thank You Presented By AditiPatni Bachelors of Computer Applications Dezyne E’Cole College www.dezyneecole.com