AFFINE TRANSFORMATIONS
An affine transformation is a transformation 𝑇: 𝑅 2 → 𝑅2 , defined by
𝑇(𝑥⃗ ) = 𝐴𝑥⃗ + 𝑎⃗ ; ∀𝑥 ∈ 𝑅2
For some 𝑎 ∈ 𝑅2 , where 𝐴 is 2 × 2 invertible matrix i.e. 𝐴𝐴−1 = 𝐼.
Remarks:
1. Every orthogonal matrix is invertible but an invertible matrix may or may not be
orthogonal.
2. Euclidean geometry is a subset of affine geometry or Affine transformations are
the generalization of Euclidean transformation.
Types of Affine transformation:
1- Scaling, 2- Stretching, 3- Shearing
1- Scaling
A transformation 𝑇: 𝑅2 → 𝑅2 , defined by:
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥 ∈ 𝑅2
Where
𝑘 0
𝐴=[ ]
0 𝑘
Is said to be a scaling by the factor k.
Note: 1. If k>1, then its dilation/enlargement.
2. If 0 ≤ 𝑘 ≤ 1, then its contraction.
Example 1: (Scaling of Square)
A square with vertices
(0, 0), (0,1), (1, 0), (1,1). Scale this square by
factor 2.
Solution: As
𝑇(𝑥⃗) = 𝐴𝑥⃗: ∀ 𝑥⃗ ∈ 𝑅2
0 2 0 0 0
𝑇[ ] = [ ][ ] = [ ]
0 0 2 0 0
0 2 0 0 0
𝑇[ ] = [ ][ ] = [ ]
1 0 2 1 2
1 2 0 1 2
𝑇[ ] = [ ][ ] = [ ]
0 0 2 0 0
1 2 0 1 2
𝑇[ ] = [ ][ ] = [ ]
1 0 2 1 2
Example 2: (Scaling of Line)
Let 𝑦 = 2𝑥 + 3 be a line. Determine the image of this line under the scaling by factor 3.
Solution:As 𝑇(𝑥⃗) = 𝐴𝑥⃗: ∀ 𝑥⃗ ∈ 𝑅2
𝑥 3 0 𝑥 3𝑥
𝑇 [𝑦] = [ ] [𝑦] = [ ]
0 3 3𝑦
𝑥′ 3𝑥
[ ]=[ ]
𝑦′ 3𝑦
𝑥′
′
𝑥 = 3𝑥 𝑥=
3
{ ′ ⟹{ ′
𝑦 = 3𝑦 𝑦
𝑦=
3
Put value of 𝑥 and 𝑦 in original equation of line:𝑦 = 2𝑥 + 3,
And get the equation of scaled line with factor 3.
𝑦 ′ = 2𝑥 ′ + 9
Example 3: (Scaling of Circle)
Determine the image of the circle
(𝑥 − 2)2 + (𝑦 − 3)2 = 4
under the scaling by factor 2.
Solution: As 𝑇(𝑥) = 𝐴𝑥: ∀ 𝑥 ∈ 𝑅2
𝑥 2 0 𝑥
𝑇 [𝑦] = [ ][ ]
0 2 𝑦
𝑥′ 2𝑥
[ ]=[ ]
𝑦′ 2𝑦
𝑥′
′
𝑥 = 2𝑥 𝑥=
2
{ ⟹{
𝑦 ′ = 2𝑦 𝑦′
𝑦=
2
Put value of 𝑥 and 𝑦 in original equation of circle:(𝑥 − 2)2 + (𝑦 − 3)2 = 4, implies
(𝑥 ′ − 4)2 + (𝑦 ′ − 6)2 = 16
This is the equation of circle by factor 2.
Example 5: (Scaling of an Ellipse)
Determine the image of an ellipse
𝑥2 𝑦2
+ =1
42 22
under the transformation of scaling by factor 2.
Solution: As 𝑇(𝑥) = 𝐴𝑥: ∀ 𝑥 ∈ 𝑅2
𝑥 2 0 𝑥
𝑇 [𝑦] = [ ][ ]
0 2 𝑦
𝑥′ 2𝑥
[ ]=[ ]
𝑦′ 2𝑦
𝑥′
′
𝑥 = 2𝑥 𝑥=
2
{ ⟹{
𝑦 ′ = 2𝑦 𝑦′
𝑦=
2
Put value of 𝑥 and 𝑦 in original equation of ellipse and get an ellipse scaled by factor 2.
𝑥 ′2 𝑦′2
+ =1
64 16
Practice Problems
Q1. Find the Image of a triangle with vertices A= (2, 2), B = (4, 3), C = (5,5), when these
are scaled by factor 2.
Q2. Find the Image of line𝑦 = 2𝑥 + 5 under the transformation of scaling by factor 3.
(𝑥−2)2 (𝑦−3)2
Q3. Find the image of an ellipse + = 1under the transformation of scaling by
4 9
factor 2.
2-Stretching
A transformation 𝑇: 𝑅 2 → 𝑅2 defined by,
𝑇(𝑥⃗) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
Is said to be stretching along x-axis by factor k if
𝑘 0
𝐴=[ ]
0 1
And along y-axis by a factor k if
1 0
𝐴=[ ]
0 𝑘
Example 1: (Stretching of a square)
Find the image of a square with vertices 𝐴(0, 0), 𝐵(1, 0), 𝐶(1, 1), 𝐷(0,1), when it is
stretched along
a) X-axis with factor 3.
b) Y-axis with factor 2.
Solution: (along x-axis) As 𝑇(𝑥⃗) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
3 0
𝐴=[ ]
0 1
0 3 0 0 0
𝑇[ ] = [ ][ ] = [ ]
0 0 1 0 0
1 3 0 1 3
𝑇[ ] = [ ][ ] = [ ]
0 0 1 0 0
1 3 0 1 3
𝑇[ ] = [ ][ ] = [ ]
1 0 1 1 1
0 3 0 0 0
𝑇[ ] = [ ][ ] = [ ]
1 0 1 1 1
Along y-axis
As 𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
1 0
𝐴=[ ]
0 2
0
𝑇[ ] =
0
1 0 0 0
[ ][ ] = [ ]
0 2 0 0
1 1 0 1 1
𝑇[ ] = [ ][ ] = [ ]
0 0 2 0 0
1 1 0 1 1
𝑇[ ] = [ ][ ] = [ ]
1 0 2 1 2
0 1 0 0 0
𝑇[ ] = [ ][ ] = [ ]
1 0 2 1 2
Example 2: (Stretching of triangle)
Find the image of a triangle with vertices 𝐴(1, 1), 𝐵(4, 1), 𝐶(3, 4), when it is
stretched along
3
a) X-axis with factor .
2
1
b) Y-axis with factor .
2
Solution: (along x-axis) As
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
3
𝐴 = [2 0]
0 1
3 3
1 0] [1] = [ ]
𝑇 [ ] = [2 2
1 1
0 1 1
3
4 0] [ 4] = [ 6]
𝑇 [ ] = [2
1 1 1
0 1
3 9
3 0] [3] = [ ]
𝑇 [ ] = [2 2
4 4
0 1 4
Along y-axis: As
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
1 0
𝐴=[ 3]
0
2
1 0 1
1 3] [1] = [3]
𝑇 [ ] = [
1 0 1
2 2
1 0 4
4 3] [4] = [3]
𝑇[ ] = [
1 0 1
2 2
1 0
3 3] [ 3] = [ 3]
𝑇[ ] = [
4 0 4 6
2
Example 3: (Stretching of Circle)
Let (𝑥 − 2)2 + (𝑦 − 1)2 = 4 be a circle. Find its equation and image under
stretching along x-axis by factor 2.
Solution: As
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
𝑥 2 0 𝑥
𝑇 [𝑦] = [ ][ ]
0 1 𝑦
𝑥′ 2𝑥
[ ′] = [ ]
𝑦 𝑦
𝑥′
𝑥 ′ = 2𝑥 𝑥=
{ ′ ⟹{ 2
𝑦 =𝑦 𝑦 = 𝑦′
Put value of 𝑥 and 𝑦 in original equation of circle and get
(𝑥 ′ − 4)2 ( 𝑦 ′ − 1)2
+ =1
16 4
It represents the ellipse.
Practice Problems
Q1. Let (𝑥 − 2)2 + (𝑦 − 1)2 = 4 be a circle. Find its equation and image under
3
stretching along Y-axis by factor .
2
(𝑥−4)2 (𝑦−1)2
Q2. Find the stretching of an ellipse + = 1 along x-axis by factor 2.
16 4
Q3. Find the image of a triangle with vertices 𝐴(1, 1), 𝐵(4, 2), 𝐶(2, 3), when it is
stretched along
a) X-axis with factor 3
b) Y-axis with factor 1.
3- Shearing
Shearing of a point along x-axis by factor k can be defined as:
The movement of point parallel to x-axis keeping the distance of the point from the x-axis.
i.e. the movement of point parallel to x-axis depending upon the y-component of the point.
• Shearing at a point along x-axis by factor k in the matrix form can be represented as
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
Where
1 𝑘
𝐴=[ ]
0 1
Example 1: (Shearing of vector)
Shear a point 𝐴 = (5,3) along x-axis by the factor 2.
Solution: As
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
𝑥 1 𝑘 𝑥 𝑥 + 𝑘𝑦
𝑇 [𝑦 ] = [ ] [𝑦 ] = [ ]
0 1 𝑦
5 1 2 5 11
𝑇[ ] = [ ][ ] = [ ]
3 0 1 3 3
Note:
1. A transformation that slants the shape of an object is called the shear transformation.
2. Shearing of an object along y-axis by factor k in matrix form can be expressed as:
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥 ∈ 𝑅2
Where
1 0
𝐴=[ ]
𝑘 1
Example 2: (Shearing of Triangle)
A triangle with vertices (0, 0), (4,2), (1, 6). Find the image of triangle when it will be
shear along y axis by factor 2.
Solution: As 𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
0 1 0 0 0
𝑇[ ] = [ ][ ] = [ ]
0 2 1 0 0
4 1 0 4 4
𝑇[ ] = [ ][ ] = [ ]
2 2 1 2 10
1 1 0 1 1
𝑇[ ] = [ ][ ] = [ ]
6 2 1 6 8
Example 3: (Shearing of Rectangle)
Consider the rectangle with vertices (0, 0), (0,2), (4, 0), (4,2). Shear this rectangle along
x-axis by factor 2.
Example 4: (Shearing of Rectangle)
Consider the rectangle with vertices (0, 0), (0,2), (4, 0), (4,2). Shear this rectangle along
y-axis by factor -3.
Example 5:
In each part describe the matrix operator corresponding to A and show it effect on unit
square
1 2 2 0 2 0
a) [ ], b) [ ], 𝑐) [ ]
0 1 0 2 0 1
Example 6: Let 𝑥 2 + 𝑦 2 = 4 be a circle. Find its equation and image under the effect of
shear parallel to x-axis by factor -2.
Solution: As
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
𝑥 1 −2 𝑥
𝑇 [𝑦 ] = [ ][ ]
0 1 𝑦
𝑥′ 𝑥 − 2𝑦
[ ′] = [ ]
𝑦 𝑦
𝑥 ′ = 𝑥 − 2𝑦 𝑥 = 𝑥 ′ + 2𝑦′
{ ⇒{
𝑦′ = 𝑦 𝑦 = 𝑦′
Put value of 𝑥 and 𝑦 in original equation of circle: 𝑥 2 + 𝑦 2 = 4
We get sheared equation of circle as (an ellipse)
𝑥 ′2 + 5𝑦 ′2 + 4𝑥 ′ 𝑦 ′ − 4 = 0
Remarks: General equation of Conics:
𝑨𝒙𝟐 + 𝑩𝒙𝒚 + 𝒄𝒚𝟐 + 𝑫𝒙 + 𝑬𝒚 + 𝑭 = 𝟎
1. If 𝐵2 − 4𝐴𝐶 < 0, 𝑤𝑒 𝑔𝑒𝑡 𝑒𝑙𝑙𝑖𝑝𝑠𝑒.
2. If 𝐵2 − 4𝐴𝐶 > 0, 𝑤𝑒 𝑔𝑒𝑡 ℎ𝑦𝑝𝑒𝑟𝑏𝑜𝑙𝑎.
3. If 𝐵2 − 4𝐴𝐶 = 0, 𝑤𝑒 𝑔𝑒𝑡 𝑝𝑎𝑟𝑎𝑏𝑜𝑙𝑎.
Example 6: Let (𝑥 + 2)2 + (𝑦 + 1)2 = 4 be a circle. Find its equation and image under
3
the effect of shear parallel to y-axis by factor .
2
Solution:As
𝑇(𝑥⃗ ) = 𝐴𝑥⃗; ∀𝑥⃗ ∈ 𝑅2
𝑥 1 0 𝑥
𝑇 [𝑦] = [3 ][ ]
1 𝑦
2
𝑥
𝑥′ 3
[ ′] = [ ]
𝑦 𝑥+𝑦
2
𝑥′ = 𝑥 𝑥 = 𝑥′
{ ′ 3 ⇒{ 3
𝑦 = 𝑥+𝑦 𝑦 = 𝑦 ′ − 𝑥′
2 2
Put value of 𝑥 and 𝑦 in original equation of circle:
(𝑥 + 2)2 + (𝑦 + 1)2 = 4
13 2
𝑥 + 𝑦 2 − 3𝑥𝑦 − 3𝑥 + 2𝑦 + 1 = 0
4
On Comparing with General equation of Conics, we get:
13
𝐴= , 𝐵 = −3, 𝐶 = 1
4
13
𝐵2 − 4𝐴𝐶 = (−3)2 − 4 ( ) (1) = 9 − 13 = −4 < 0
4
So we get ellipse.
Example 7: Let (𝑥 − 2)2 + (𝑦 − 1)2 = 4 be a circle. Find its equation and image under
the effect of shear parallel to x-axis by factor 2.
Python Codes:
Example 2: Scaling, Rotation, and Shearing
import numpy as np
import matplotlib.pyplot as plt
def apply_transformation(matrix, points):
return np.dot(matrix, points.T).T
def plot_shape(points, label, color):
points = np.vstack([points, points[0]]) # Close the shape
plt.plot(points[:, 0], points[:, 1], label=label, color=color, linewidth=2)
square = np.array([[0, 0], [1, 0], [1, 1], [0, 1]])
scaling_matrix = np.array([[2, 0], [0, 2]]) # Scale x and y by 2
scaled_square = apply_transformation(scaling_matrix, square)
theta = np.pi / 4
rotation_matrix = np.array([[np.cos(theta), -np.sin(theta)],
[np.sin(theta), np.cos(theta)]])
rotated_square = apply_transformation(rotation_matrix, square)
shear_matrix = np.array([[1, 1.5], [0, 1]]) # Shear in x-direction
sheared_square = apply_transformation(shear_matrix, square)
plt.figure(figsize=(8, 8))
plot_shape(square, "Original Square", "blue")
plot_shape(scaled_square, "Scaled Square", "red")
plot_shape(rotated_square, "Rotated Square", "green")
plot_shape(sheared_square, "Sheared Square", "purple")
plt.title("Linear Transformations: Scaling, Rotation, and Shearing")
plt.axis("equal")
plt.legend()
plt.grid()
plt.show()
[1, 4], [3, 7], [5, 4]
Coding Assignment
Use linear transformations to Design a House with geometric shapes (rectangles, triangles, squares, etc.).
1. create a house using basic geometric shapes. For example:
A square for the body of the house with vertices [2, 0], [2, 2], [4, 2], [4, 0]
A triangle for the roof with vertices [1, 4], [3, 7], [5, 4]
A rectangle for the door with vertices [1, 0], [5, 0], [5, 4], [1, 4]
2. Apply Linear Transformations:
Scaling: Scale the shapes to make the house bigger or smaller.
Rotation: Rotate the house or individual shapes.
Translation: Move the house to a different location on the plane.
3. Python Code: Write Python code to perform the linear transformations using libraries like
matplotlib for visualization and numpy for matrix operations.