SlideShare a Scribd company logo
2D Transformations with Matrices
Matrices
 a1,1

A = a2,1
 a3,1


a1, 2
a2 , 2
a3, 2

a1,3 

a2 , 3 
a3,3 


•

A matrix is a rectangular array of numbers.

•

A general matrix will be represented by an upper-case italicised
letter.

•

The element on the ith row and jth column is denoted by ai,j. Note
that we start indexing at 1, whereas C indexes arrays from 0.
Matrices – Addition
• Given two matrices A and B if we want to add B to A
(that is form A+B) then if A is (n×m), B must be (n×m),
Otherwise, A+B is not defined.
• The addition produces a result, C = A+B, with elements:
Ci , j = Ai , j + Bi , j

1 2 5 6 1 + 5 2 + 6  6 8 
3 4 + 7 8 = 3 + 7 4 + 8 = 10 12

 
 
 

Matrices – Multiplication
• Given two matrices A and B if we want to multiply B by A (that
is form AB) then if A is (n×m), B must be (m×p), i.e., the
number of columns in A must be equal to the number of rows
in B. Otherwise, AB is not defined.
• The multiplication produces a result, C = AB, with elements:
m

(Basically we multiply Ci , j = ∑ aik bkj of A with the first column of
the first row
k =1
B and put this in the c1,1 element of C. And so on…).
Matrices – Multiplication (Examples)
2×6+ 6×3+ 7×2=44

2 6 7 6 8 44 76
4 5 8 × 3 3 = 55 95

 
 

9 2 3 2 6 66 96

 
 

6 8
 2 6 
×  3 3
 4 5


  2 6



Undefined!
2x2 x 3x2 2!=3

2x2 x 2x4 x 4x4 is allowed. Result is 2x4 matrix
Matrices -- Basics
• Unlike scalar multiplication, AB ≠ BA
• Matrix multiplication distributes over addition:
A(B+C) = AB + AC
•

Identity matrix for multiplication is defined as I.

• The transpose of a matrix, A, is either denoted AT or A’ is
obtained by swapping the rows and columns of A:
 a1,1
A=
a2,1

a1, 2
a2 , 2

 a1,1
a1,3 

⇒ A' = a1, 2
a2 , 3 

 a1,3


a2,1 

a2 , 2 
a2 , 3 

2D Geometrical Transformations

Translate

Rotate

Shear

Scale
Translate Points
Recall.. We can translate points in the (x, y) plane to new positions
by adding translation amounts to the coordinates of the points. For
each point P(x, y) to be moved by dx units parallel to the x axis and by dy
units parallel to the y axis, to the new point P’(x’, y’ ). The translation has
the following form:

x' = x + d x

P’(x’,y’)
dy
dx

P(x,y)

y' = y + d y
In matrix format:

 x '   x  d x 
 y ' =  y  + d 
     y
d x 
If we define the translation matrix T =   , then we have P’ =P + T.
d y 
Scale Points
Points can be scaled (stretched) by sx along the x axis and by sy
along the y axis into the new points by the multiplications:
We can specify how much bigger or smaller by means of a “scale factor”
To double the size of an object we use a scale factor of 2, to half the size of
an obejct we use a scale factor of 0.5

x' = s x x

P(x,y)

y
s y• y

P’(x’,y’)
s x• x

s x
If we define S = 
0

x

y' = s y y
 x'  s x
 y ' =  0
  

0
, then we have P’ =SP
sy 


0 x 
sy  y
 
Rotate Points (cont.)
Points can be rotated through an angle θ about the origin:

| OP' |=| OP |= l
x' =| OP' | cos(α + θ ) = l cos(α + θ )
= l cos α cos θ − l sin α sin θ
= x cos θ − y sin θ
y ' =| OP' | sin(α + θ ) = l sin(α + θ )
= l cos α sin θ + l sin α cos θ
= x sin θ + y cos θ

P’(x’,y’)
y
y’

O

θ

P(x,y)

l
α
x’

 x'  cos θ
 y ' =  sin θ
  

x

− sin θ   x 
cos θ   y 
 

P’ =RP
Review…
• Translate:
• Scale:
• Rotate:

P’ = P+T
P’ = SP
P’ = RP

• Spot the odd one out…
– Multiplying versus adding matrix…
– Ideally, all transformations would be the same..
• easier to code

• Solution: Homogeneous Coordinates
Homogeneous Coordinates
For a given 2D coordinates (x, y), we introduce a third dimension:
[x, y, 1]
In general, a homogeneous coordinates for a 2D point has the form:
[x, y, W]
Two homogeneous coordinates [x, y, W] and [x’, y’, W’] are said to be of the
same (or equivalent) if
x = kx’
y = ky’
W = kW’

for some k ≠ 0

eg: [2, 3, 6] = [4, 6, 12]
where k=2

Therefore any [x, y, W] can be normalised by dividing each element by W:
[x/W, y/W, 1]
Homogeneous Transformations
Now, redefine the translation by using homogeneous coordinates:
x '  1
 y ' = 0
  
1  0
  

x '  x  d x 
 y ' =  y  + d 
     y

0
1
0

d x x 
d y  y 
 
1 1 
 

P' = T × P

Similarly, we have:
Scaling

x'  s x
 y ' =  0
  
1   0
  
P’

=

Rotation

0

0 x 
0  y 
 
11 
 

S

×

0
sy

P

x'  cos θ
 y ' = sin θ
  
1   0
  
P’

=

− sin θ
cos θ

0 x 
0  y 
 
11 
 

0
R

×

P
Composition of 2D Transformations
1. Additivity of successive translations
We want to translate a point P to P’ by T(dx1, dy1) and then to P’’ by
another T(dx2, dy2)
P ' ' = T (d x 2 , d y 2 ) P ' = T (d x 2 , d y 2 )[T (d x1 , d y1 ) P ]
On the other hand, we can define T21= T(dx1, dy1) T(dx2, dy2) first, then
apply T21 to P:

P ' ' = T21 P

where

T21 = T ( d x 2 , d y 2 )T (d x1 , d y1 )
1 0 d x 2  1 0 d x1 
=  0 1 d y 2   0 1 d y1 



0 0 1  0 0 1 




1 0 d x1 + d x 2 
=  0 1 d y1 + d y 2 


0 0

1


Examples of Composite 2D Transformations

T(-1,2)

(1,3)

T(1,-1)

(2,1)

1
T21 = 0

0

1
= 0

0


0
1
0
0
1
0

1  1 0 − 1
− 1 0 1 2 


1  0 0 1 


0
1

1


(2,2)
Composition of 2D Transformations (cont.)
2. Multiplicativity of successive scalings
P ' ' = S ( s x 2 , s y 2 )[ S ( s x1 , s y1 ) P]
= [ S ( s x 2 , s y 2 ) S ( s x1 , s y1 )]P
= S 21 P

where

S 21 = S ( s x 2 , s y 2 ) S ( s x1 , s y1 )
s x 2
= 0

0


0
sy2
0

s x 2 * s x1
= 0

 0


0s x1
0  0

1  0

0
s y 2 * s y1
0

0
s y1
0
0
0

1


0
0

1

Composition of 2D Transformations (cont.)
3. Additivity of successive rotations
P ' ' = R (θ 2 )[ R (θ1 ) P ]
= [ R (θ 2 ) R (θ1 )]P
= R21 P

where

R21 = R (θ2 ) R (θ1 )
cos θ2
= sin θ2

 0


− sin θ2
cos θ2
0

cos(θ2 +θ1 )
= sin(θ2 +θ1 )


0


0cos θ1
0sin θ1

1  0


− sin(θ2 +θ1 )
cos(θ2 +θ1 )
0

− sin θ1
cos θ1
0
0
0

1


0
0

1

Composition of 2D Transformations (cont.)
4. Different types of elementary transformations discussed above
can be concatenated as well.
P ' = R (θ )[T (d x , d y ) P ]
= [ R (θ )T (d x , d y )]P
= MP

where

M = R (θ )T ( d x , d y )
Consider the following two questions:
1) translate a line segment P1 P2, say, by -1 units in the x direction
and -2 units in the y direction.
P2(3,3)
P’2

P1(1,2)
P’1

2). Rotate a line segment P1 P2, say by θ degrees counter clockwise,
about P1.

P’2

P2(3,3)
P1(1,2)

θ
P’1
Other Than Point Transformations…
Translate Lines:

translate both endpoints, then join them.

Scale or Rotate Lines: More complex. For example, consider to
rotate an arbitrary line about a point P1,
three steps are needed:
1). Translate such that P1 is at the origin;
2). Rotate;
3). Translate such that the point at the origin
returns to P1.
P2

P2(3,3)
T(-1,-2)
P2(2,1)

P1(1,2)
P1

P2

R(θ)

θ
P1

T(1,2)

P1
Another Example.

Translate

Scale

Translate

Rotate
Order Matters!
As we said, the order for composition of 2D geometrical transformations matters,
because, in general, matrix multiplication is not commutative. However, it is easy
to show that, in the following four cases, commutativity holds:
1).
Translation + Translation
2).
Scaling + Scaling
3).
Rotation + Rotation
4).
Scaling (with sx = sy) + Rotation
just to verify case 4:
M 1 = S ( s x , s y ) R (θ )

M 2 = R (θ ) S ( s x , s y )

0cos θ − sin θ
s y 0sin θ
cos θ

0 1  0
0

s x * cos θ − s x * sin θ 0
=  s y * sin θ
s y * cos θ 0



0
0
1


s x
= 0

0


0

0
0

1


if sx = sy, M1 = M2.

cos θ
= sin θ

 0


− sin θ

0s x
cos θ 0 0

0
1  0

s x * cos θ − s y * sin θ
=  s x * sin θ
s y * cos θ


0
0


0
sy
0
0
0

1


0
0

1

Rigid-Body vs. Affine Transformations
A transformation matrix of the form
r11
r
 21
0


r12
r22
0

tx 
ty 

1


where the upper 2×2 sub-matrix is orthogonal, preserves angles and
lengths. Such transforms are called rigid-body transformations,
because the body or object being transformed is not distorted in any
way. An arbitrary sequence of rotation and translation matrices
creates a matrix of this form.
The product of an arbitrary sequence of rotation, translations, and
scale matrices will cause an affine transformation, which have the
property of preserving parallelism of lines, but not of lengths and
angles.
Rigid-Body vs. Affine Transformations (cont.)
Rigid- body
Transformation

Affine
Transformation

45º

Unit cube

Scale in x, not in y

Shear transformation is also affine.

Shear in the x direction

1
SH x = 0

0


a
1
0

0
0

1


1
SH y = b

0


Shear in the y direction

0
1
0

0
0

1


More Related Content

What's hot

1579 parametric equations
1579 parametric equations1579 parametric equations
1579 parametric equations
Dr Fereidoun Dejahang
 
5 parametric equations, tangents and curve lengths in polar coordinates
5 parametric equations, tangents and curve lengths in polar coordinates5 parametric equations, tangents and curve lengths in polar coordinates
5 parametric equations, tangents and curve lengths in polar coordinatesmath267
 
Double_Integral.pdf
Double_Integral.pdfDouble_Integral.pdf
Double_Integral.pdf
d00a7ece
 
2 3 Bzca5e
2 3 Bzca5e2 3 Bzca5e
2 3 Bzca5esilvia
 
Harder trig equations
Harder trig equationsHarder trig equations
Harder trig equations
JJkedst
 
Integration
IntegrationIntegration
Integration
suefee
 
41 trig equations
41 trig equations41 trig equations
41 trig equations
JJkedst
 
Bezier Curve in Computer Graphics
Bezier Curve in Computer GraphicsBezier Curve in Computer Graphics
Bezier Curve in Computer Graphics
Faruk Ahmad
 
Hull White model presentation
Hull White model presentationHull White model presentation
Hull White model presentation
Stephan Chang
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential Equations
Meenakshisundaram N
 
4.6 radical equations
4.6 radical equations4.6 radical equations
4.6 radical equationsmath123b
 
CMSC 56 | Lecture 17: Matrices
CMSC 56 | Lecture 17: MatricesCMSC 56 | Lecture 17: Matrices
CMSC 56 | Lecture 17: Matrices
allyn joy calcaben
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algoMohd Arif
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.Mohd Arif
 
Metric space
Metric spaceMetric space
Metric space
NaliniSPatil
 
CMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of FunctionsCMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of Functions
allyn joy calcaben
 

What's hot (18)

1579 parametric equations
1579 parametric equations1579 parametric equations
1579 parametric equations
 
5 parametric equations, tangents and curve lengths in polar coordinates
5 parametric equations, tangents and curve lengths in polar coordinates5 parametric equations, tangents and curve lengths in polar coordinates
5 parametric equations, tangents and curve lengths in polar coordinates
 
Double_Integral.pdf
Double_Integral.pdfDouble_Integral.pdf
Double_Integral.pdf
 
2 3 Bzca5e
2 3 Bzca5e2 3 Bzca5e
2 3 Bzca5e
 
Differentiation
DifferentiationDifferentiation
Differentiation
 
Harder trig equations
Harder trig equationsHarder trig equations
Harder trig equations
 
Integration
IntegrationIntegration
Integration
 
Alin 2.2 2.4
Alin 2.2 2.4Alin 2.2 2.4
Alin 2.2 2.4
 
41 trig equations
41 trig equations41 trig equations
41 trig equations
 
Bezier Curve in Computer Graphics
Bezier Curve in Computer GraphicsBezier Curve in Computer Graphics
Bezier Curve in Computer Graphics
 
Hull White model presentation
Hull White model presentationHull White model presentation
Hull White model presentation
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential Equations
 
4.6 radical equations
4.6 radical equations4.6 radical equations
4.6 radical equations
 
CMSC 56 | Lecture 17: Matrices
CMSC 56 | Lecture 17: MatricesCMSC 56 | Lecture 17: Matrices
CMSC 56 | Lecture 17: Matrices
 
Midpoint circle algo
Midpoint circle algoMidpoint circle algo
Midpoint circle algo
 
Ellipses drawing algo.
Ellipses drawing algo.Ellipses drawing algo.
Ellipses drawing algo.
 
Metric space
Metric spaceMetric space
Metric space
 
CMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of FunctionsCMSC 56 | Lecture 8: Growth of Functions
CMSC 56 | Lecture 8: Growth of Functions
 

Viewers also liked

Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1georgiepaige
 
Robert Lewis Balfour Stevenson
Robert Lewis Balfour StevensonRobert Lewis Balfour Stevenson
Robert Lewis Balfour Stevensonowl_cat
 
Localitera.com - Opportunity execution project
Localitera.com - Opportunity execution projectLocalitera.com - Opportunity execution project
Localitera.com - Opportunity execution projectІван Подолян
 
Nearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- Unosquare
Nearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- UnosquareNearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- Unosquare
Nearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- Unosquare
Nearshore Americas
 
Nearshore Nexus 13- IT Outsourcing Comes of Age by Xerox
Nearshore Nexus 13- IT Outsourcing Comes of Age by XeroxNearshore Nexus 13- IT Outsourcing Comes of Age by Xerox
Nearshore Nexus 13- IT Outsourcing Comes of Age by Xerox
Nearshore Americas
 
Nearshore Nexus 13- Mexico’s Hemispheric Role in IT Leadership
Nearshore Nexus 13- Mexico’s Hemispheric Role in IT LeadershipNearshore Nexus 13- Mexico’s Hemispheric Role in IT Leadership
Nearshore Nexus 13- Mexico’s Hemispheric Role in IT Leadership
Nearshore Americas
 
Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...
Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...
Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...
Nearshore Americas
 
test your intelligence
test your intelligencetest your intelligence
test your intelligence
Adriano Milani
 
The idiot test game
The idiot test gameThe idiot test game
The idiot test game
Adriano Milani
 
Irish national cuisine
Irish national cuisineIrish national cuisine
Irish national cuisineowl_cat
 
Agriculturesciece past paper
Agriculturesciece past paperAgriculturesciece past paper
Agriculturesciece past paperjermol
 
The not so impossible quiz
The not so impossible quizThe not so impossible quiz
The not so impossible quiz
Adriano Milani
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 d
xyz120
 
The ultimate powerpoint mouse maze version 3.0.pps
The ultimate powerpoint mouse maze version 3.0.ppsThe ultimate powerpoint mouse maze version 3.0.pps
The ultimate powerpoint mouse maze version 3.0.pps
Adriano Milani
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinatesTarun Gehlot
 
Agriculture science past paper
Agriculture science past paperAgriculture science past paper
Agriculture science past paperjermol
 

Viewers also liked (18)

Evaluation question 1
Evaluation question 1Evaluation question 1
Evaluation question 1
 
Localitera presentation
Localitera presentationLocalitera presentation
Localitera presentation
 
Robert Lewis Balfour Stevenson
Robert Lewis Balfour StevensonRobert Lewis Balfour Stevenson
Robert Lewis Balfour Stevenson
 
Localitera.com - Opportunity execution project
Localitera.com - Opportunity execution projectLocalitera.com - Opportunity execution project
Localitera.com - Opportunity execution project
 
Nearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- Unosquare
Nearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- UnosquareNearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- Unosquare
Nearshore Nexus 13- Real People and Real Social Impact -Mike Barrett- Unosquare
 
Nearshore Nexus 13- IT Outsourcing Comes of Age by Xerox
Nearshore Nexus 13- IT Outsourcing Comes of Age by XeroxNearshore Nexus 13- IT Outsourcing Comes of Age by Xerox
Nearshore Nexus 13- IT Outsourcing Comes of Age by Xerox
 
Scary maze
Scary mazeScary maze
Scary maze
 
Nearshore Nexus 13- Mexico’s Hemispheric Role in IT Leadership
Nearshore Nexus 13- Mexico’s Hemispheric Role in IT LeadershipNearshore Nexus 13- Mexico’s Hemispheric Role in IT Leadership
Nearshore Nexus 13- Mexico’s Hemispheric Role in IT Leadership
 
Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...
Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...
Nearshore Nexus- Brasil IT+: Collaborating to Meet Productivity and Competiti...
 
test your intelligence
test your intelligencetest your intelligence
test your intelligence
 
The idiot test game
The idiot test gameThe idiot test game
The idiot test game
 
Irish national cuisine
Irish national cuisineIrish national cuisine
Irish national cuisine
 
Agriculturesciece past paper
Agriculturesciece past paperAgriculturesciece past paper
Agriculturesciece past paper
 
The not so impossible quiz
The not so impossible quizThe not so impossible quiz
The not so impossible quiz
 
Matrix 2 d
Matrix 2 dMatrix 2 d
Matrix 2 d
 
The ultimate powerpoint mouse maze version 3.0.pps
The ultimate powerpoint mouse maze version 3.0.ppsThe ultimate powerpoint mouse maze version 3.0.pps
The ultimate powerpoint mouse maze version 3.0.pps
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates
 
Agriculture science past paper
Agriculture science past paperAgriculture science past paper
Agriculture science past paper
 

Similar to Matrix 2 d

Computer Graphics - transformations in 2d
Computer Graphics - transformations in 2dComputer Graphics - transformations in 2d
Computer Graphics - transformations in 2d
Hisham Al Kurdi, EAVA, DMC-D-4K, HCCA-P, HCAA-D
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
2013901097
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
Ankit Garg
 
Transforms UNIt 2
Transforms UNIt 2 Transforms UNIt 2
Transforms UNIt 2
sandeep kumbhkar
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
FahadYaqoob5
 
Modeling Transformations
Modeling TransformationsModeling Transformations
Modeling Transformations
Tarun Gehlot
 
2D-transformation-1.pdf
2D-transformation-1.pdf2D-transformation-1.pdf
2D-transformation-1.pdf
bcanawakadalcollege
 
2D transformation (Computer Graphics)
2D transformation (Computer Graphics)2D transformation (Computer Graphics)
2D transformation (Computer Graphics)
Timbal Mayank
 
Applications of Differential Calculus in real life
Applications of Differential Calculus in real life Applications of Differential Calculus in real life
Applications of Differential Calculus in real life
OlooPundit
 
Plano numerico
Plano numericoPlano numerico
Plano numerico
YignethAraujo
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Bala Murali
 
06.Transformation.ppt
06.Transformation.ppt06.Transformation.ppt
06.Transformation.ppt
RobinAhmedSaikat
 
D4 trigonometrypdf
D4 trigonometrypdfD4 trigonometrypdf
D4 trigonometrypdf
Krysleng Lynlyn
 
TABREZ KHAN.ppt
TABREZ KHAN.pptTABREZ KHAN.ppt
TABREZ KHAN.ppt
TabrezKhan733764
 
2-D Transformations.pdf
2-D Transformations.pdf2-D Transformations.pdf
2-D Transformations.pdf
Mattupallipardhu
 
2d transformations
2d transformations2d transformations
2d transformations
rajeshranjithsingh
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
Amit Kapoor
 
Chapter 8.pptx
Chapter 8.pptxChapter 8.pptx
Chapter 8.pptx
Happy Ladher
 
1513 circles
1513 circles1513 circles
1513 circles
Dr Fereidoun Dejahang
 

Similar to Matrix 2 d (20)

Computer Graphics - transformations in 2d
Computer Graphics - transformations in 2dComputer Graphics - transformations in 2d
Computer Graphics - transformations in 2d
 
Computer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2DComputer Graphic - Transformations in 2D
Computer Graphic - Transformations in 2D
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
 
Transforms UNIt 2
Transforms UNIt 2 Transforms UNIt 2
Transforms UNIt 2
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Modeling Transformations
Modeling TransformationsModeling Transformations
Modeling Transformations
 
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)
 
Applications of Differential Calculus in real life
Applications of Differential Calculus in real life Applications of Differential Calculus in real life
Applications of Differential Calculus in real life
 
Plano numerico
Plano numericoPlano numerico
Plano numerico
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
06.Transformation.ppt
06.Transformation.ppt06.Transformation.ppt
06.Transformation.ppt
 
D4 trigonometrypdf
D4 trigonometrypdfD4 trigonometrypdf
D4 trigonometrypdf
 
TABREZ KHAN.ppt
TABREZ KHAN.pptTABREZ KHAN.ppt
TABREZ KHAN.ppt
 
2-D Transformations.pdf
2-D Transformations.pdf2-D Transformations.pdf
2-D Transformations.pdf
 
2d transformations
2d transformations2d transformations
2d transformations
 
2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)2 d transformations by amit kumar (maimt)
2 d transformations by amit kumar (maimt)
 
Chapter 8.pptx
Chapter 8.pptxChapter 8.pptx
Chapter 8.pptx
 
1513 circles
1513 circles1513 circles
1513 circles
 

Recently uploaded

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

Matrix 2 d

  • 2. Matrices  a1,1  A = a2,1  a3,1  a1, 2 a2 , 2 a3, 2 a1,3   a2 , 3  a3,3   • A matrix is a rectangular array of numbers. • A general matrix will be represented by an upper-case italicised letter. • The element on the ith row and jth column is denoted by ai,j. Note that we start indexing at 1, whereas C indexes arrays from 0.
  • 3. Matrices – Addition • Given two matrices A and B if we want to add B to A (that is form A+B) then if A is (n×m), B must be (n×m), Otherwise, A+B is not defined. • The addition produces a result, C = A+B, with elements: Ci , j = Ai , j + Bi , j 1 2 5 6 1 + 5 2 + 6  6 8  3 4 + 7 8 = 3 + 7 4 + 8 = 10 12        
  • 4. Matrices – Multiplication • Given two matrices A and B if we want to multiply B by A (that is form AB) then if A is (n×m), B must be (m×p), i.e., the number of columns in A must be equal to the number of rows in B. Otherwise, AB is not defined. • The multiplication produces a result, C = AB, with elements: m (Basically we multiply Ci , j = ∑ aik bkj of A with the first column of the first row k =1 B and put this in the c1,1 element of C. And so on…).
  • 5. Matrices – Multiplication (Examples) 2×6+ 6×3+ 7×2=44 2 6 7 6 8 44 76 4 5 8 × 3 3 = 55 95       9 2 3 2 6 66 96       6 8  2 6  ×  3 3  4 5     2 6   Undefined! 2x2 x 3x2 2!=3 2x2 x 2x4 x 4x4 is allowed. Result is 2x4 matrix
  • 6. Matrices -- Basics • Unlike scalar multiplication, AB ≠ BA • Matrix multiplication distributes over addition: A(B+C) = AB + AC • Identity matrix for multiplication is defined as I. • The transpose of a matrix, A, is either denoted AT or A’ is obtained by swapping the rows and columns of A:  a1,1 A= a2,1 a1, 2 a2 , 2  a1,1 a1,3   ⇒ A' = a1, 2 a2 , 3    a1,3  a2,1   a2 , 2  a2 , 3  
  • 8. Translate Points Recall.. We can translate points in the (x, y) plane to new positions by adding translation amounts to the coordinates of the points. For each point P(x, y) to be moved by dx units parallel to the x axis and by dy units parallel to the y axis, to the new point P’(x’, y’ ). The translation has the following form: x' = x + d x P’(x’,y’) dy dx P(x,y) y' = y + d y In matrix format:  x '   x  d x   y ' =  y  + d       y d x  If we define the translation matrix T =   , then we have P’ =P + T. d y 
  • 9. Scale Points Points can be scaled (stretched) by sx along the x axis and by sy along the y axis into the new points by the multiplications: We can specify how much bigger or smaller by means of a “scale factor” To double the size of an object we use a scale factor of 2, to half the size of an obejct we use a scale factor of 0.5 x' = s x x P(x,y) y s y• y P’(x’,y’) s x• x s x If we define S =  0 x y' = s y y  x'  s x  y ' =  0    0 , then we have P’ =SP sy   0 x  sy  y  
  • 10. Rotate Points (cont.) Points can be rotated through an angle θ about the origin: | OP' |=| OP |= l x' =| OP' | cos(α + θ ) = l cos(α + θ ) = l cos α cos θ − l sin α sin θ = x cos θ − y sin θ y ' =| OP' | sin(α + θ ) = l sin(α + θ ) = l cos α sin θ + l sin α cos θ = x sin θ + y cos θ P’(x’,y’) y y’ O θ P(x,y) l α x’  x'  cos θ  y ' =  sin θ    x − sin θ   x  cos θ   y    P’ =RP
  • 11. Review… • Translate: • Scale: • Rotate: P’ = P+T P’ = SP P’ = RP • Spot the odd one out… – Multiplying versus adding matrix… – Ideally, all transformations would be the same.. • easier to code • Solution: Homogeneous Coordinates
  • 12. Homogeneous Coordinates For a given 2D coordinates (x, y), we introduce a third dimension: [x, y, 1] In general, a homogeneous coordinates for a 2D point has the form: [x, y, W] Two homogeneous coordinates [x, y, W] and [x’, y’, W’] are said to be of the same (or equivalent) if x = kx’ y = ky’ W = kW’ for some k ≠ 0 eg: [2, 3, 6] = [4, 6, 12] where k=2 Therefore any [x, y, W] can be normalised by dividing each element by W: [x/W, y/W, 1]
  • 13. Homogeneous Transformations Now, redefine the translation by using homogeneous coordinates: x '  1  y ' = 0    1  0    x '  x  d x   y ' =  y  + d       y 0 1 0 d x x  d y  y    1 1    P' = T × P Similarly, we have: Scaling x'  s x  y ' =  0    1   0    P’ = Rotation 0 0 x  0  y    11    S × 0 sy P x'  cos θ  y ' = sin θ    1   0    P’ = − sin θ cos θ 0 x  0  y    11    0 R × P
  • 14. Composition of 2D Transformations 1. Additivity of successive translations We want to translate a point P to P’ by T(dx1, dy1) and then to P’’ by another T(dx2, dy2) P ' ' = T (d x 2 , d y 2 ) P ' = T (d x 2 , d y 2 )[T (d x1 , d y1 ) P ] On the other hand, we can define T21= T(dx1, dy1) T(dx2, dy2) first, then apply T21 to P: P ' ' = T21 P where T21 = T ( d x 2 , d y 2 )T (d x1 , d y1 ) 1 0 d x 2  1 0 d x1  =  0 1 d y 2   0 1 d y1     0 0 1  0 0 1     1 0 d x1 + d x 2  =  0 1 d y1 + d y 2    0 0  1  
  • 15. Examples of Composite 2D Transformations T(-1,2) (1,3) T(1,-1) (2,1) 1 T21 = 0  0  1 = 0  0  0 1 0 0 1 0 1  1 0 − 1 − 1 0 1 2    1  0 0 1    0 1  1  (2,2)
  • 16. Composition of 2D Transformations (cont.) 2. Multiplicativity of successive scalings P ' ' = S ( s x 2 , s y 2 )[ S ( s x1 , s y1 ) P] = [ S ( s x 2 , s y 2 ) S ( s x1 , s y1 )]P = S 21 P where S 21 = S ( s x 2 , s y 2 ) S ( s x1 , s y1 ) s x 2 = 0  0  0 sy2 0 s x 2 * s x1 = 0   0  0s x1 0  0  1  0  0 s y 2 * s y1 0 0 s y1 0 0 0  1  0 0  1 
  • 17. Composition of 2D Transformations (cont.) 3. Additivity of successive rotations P ' ' = R (θ 2 )[ R (θ1 ) P ] = [ R (θ 2 ) R (θ1 )]P = R21 P where R21 = R (θ2 ) R (θ1 ) cos θ2 = sin θ2   0  − sin θ2 cos θ2 0 cos(θ2 +θ1 ) = sin(θ2 +θ1 )   0  0cos θ1 0sin θ1  1  0  − sin(θ2 +θ1 ) cos(θ2 +θ1 ) 0 − sin θ1 cos θ1 0 0 0  1  0 0  1 
  • 18. Composition of 2D Transformations (cont.) 4. Different types of elementary transformations discussed above can be concatenated as well. P ' = R (θ )[T (d x , d y ) P ] = [ R (θ )T (d x , d y )]P = MP where M = R (θ )T ( d x , d y )
  • 19. Consider the following two questions: 1) translate a line segment P1 P2, say, by -1 units in the x direction and -2 units in the y direction. P2(3,3) P’2 P1(1,2) P’1 2). Rotate a line segment P1 P2, say by θ degrees counter clockwise, about P1. P’2 P2(3,3) P1(1,2) θ P’1
  • 20. Other Than Point Transformations… Translate Lines: translate both endpoints, then join them. Scale or Rotate Lines: More complex. For example, consider to rotate an arbitrary line about a point P1, three steps are needed: 1). Translate such that P1 is at the origin; 2). Rotate; 3). Translate such that the point at the origin returns to P1. P2 P2(3,3) T(-1,-2) P2(2,1) P1(1,2) P1 P2 R(θ) θ P1 T(1,2) P1
  • 22. Order Matters! As we said, the order for composition of 2D geometrical transformations matters, because, in general, matrix multiplication is not commutative. However, it is easy to show that, in the following four cases, commutativity holds: 1). Translation + Translation 2). Scaling + Scaling 3). Rotation + Rotation 4). Scaling (with sx = sy) + Rotation just to verify case 4: M 1 = S ( s x , s y ) R (θ ) M 2 = R (θ ) S ( s x , s y ) 0cos θ − sin θ s y 0sin θ cos θ  0 1  0 0  s x * cos θ − s x * sin θ 0 =  s y * sin θ s y * cos θ 0    0 0 1   s x = 0  0  0 0 0  1  if sx = sy, M1 = M2. cos θ = sin θ   0  − sin θ 0s x cos θ 0 0  0 1  0  s x * cos θ − s y * sin θ =  s x * sin θ s y * cos θ   0 0  0 sy 0 0 0  1  0 0  1 
  • 23. Rigid-Body vs. Affine Transformations A transformation matrix of the form r11 r  21 0  r12 r22 0 tx  ty   1  where the upper 2×2 sub-matrix is orthogonal, preserves angles and lengths. Such transforms are called rigid-body transformations, because the body or object being transformed is not distorted in any way. An arbitrary sequence of rotation and translation matrices creates a matrix of this form. The product of an arbitrary sequence of rotation, translations, and scale matrices will cause an affine transformation, which have the property of preserving parallelism of lines, but not of lengths and angles.
  • 24. Rigid-Body vs. Affine Transformations (cont.) Rigid- body Transformation Affine Transformation 45º Unit cube Scale in x, not in y Shear transformation is also affine. Shear in the x direction 1 SH x = 0  0  a 1 0 0 0  1  1 SH y = b  0  Shear in the y direction 0 1 0 0 0  1 