0% found this document useful (0 votes)
12 views12 pages

Lab Report (Linear Transformations (II) )

The lab report investigates linear transformations, focusing on their composition and visual impact on a structured 2D grid. It includes detailed analysis of transformations T6, T7, T8, and T9, demonstrating their effects through MATLAB simulations and visualizations. The report emphasizes the non-commutative nature of matrix multiplication and the significance of transformation order in altering the input space.

Uploaded by

b23087
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views12 pages

Lab Report (Linear Transformations (II) )

The lab report investigates linear transformations, focusing on their composition and visual impact on a structured 2D grid. It includes detailed analysis of transformations T6, T7, T8, and T9, demonstrating their effects through MATLAB simulations and visualizations. The report emphasizes the non-commutative nature of matrix multiplication and the significance of transformation order in altering the input space.

Uploaded by

b23087
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Lab Report:

Linear Transformations (II)


Bhoomi​
B23255
Objective
This lab aims to investigate the composition of linear transformations and their visual impact on
the input space. The primary objectives are:

1.​ Visualizing the Input Space: Construct a structured 2D grid to represent the input
space in , providing a clear reference for transformations.
2.​ Applying and Analyzing Transformations: Implement predefined transformation
matrices, observing their individual impact on spatial orientation, stretching, shearing,
and reflection.
3.​ Examining Sequential Transformations: Investigate how successive transformations
modify the input space, highlighting the importance of matrix multiplication order and its
implications in linear algebra.
4.​ Interpreting Geometric Transformations: Use computational simulations to analyze
changes in grid structures, gaining insights into real-world applications such as computer
graphics, physics simulations, and engineering models.

Part 1: Input Space Plot

Objective:-

To generate a structured 2D grid representation of the input space in ℝ2, covering x- and
y-coordinates from -2 to 3. I have represented horizontal grid lines and vertical grid lines
differently with solid red and blue dashed lines respectively to make them easily differentiable.

Simulation Setup:-

●​ The coordinate grid is defined using MATLAB’s meshgrid function, which generates a
matrix representation of the x- and y-coordinates over the specified range.
●​ The structured grid consists of horizontal and vertical lines:
○​ Horizontal grid lines are represented as solid red ('r-'), emphasizing row-wise
coordinate variations.
○​ Vertical grid lines are represented as dashed blue ('b--'), highlighting
column-wise variations in the space.
●​ Axis labels, titles, and appropriate limits are set to ensure clarity in visualization.
●​ The resulting plot provides a clear representation of the reference grid before applying
transformations.
MATLAB Code:-

[X, Y] = meshgrid(-2:1:3, -2:1:3);


figure;
hold on;
for i = 1:size(Y, 1)
plot(X(i, :), Y(i, :), 'r-', 'LineWidth', 1.5);
end

for i = 1:size(X, 2)
plot(X(:, i), Y(:, i), 'b--', 'LineWidth', 1.5);
end

hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('2D Grid Visualization');
axis([-2 3 -2 3]);
axis equal;
grid on;

Results and Inference:-

●​ The generated plot successfully delineates the structured input space.


●​ The red and blue lines effectively visualize coordinate transformations by distinguishing
horizontal and vertical separations.

Input Space Visualization:


Part 2: Transformation Analysis (Question 1)
Objective

To examine the effects of sequentially applying transformations T6 and T7 to the input space.
And also to examine the effect of applying their composition on the input space.

Transformation Matrices:-

The assignment provides us with two matrices T6 and T7 and we need to show the impacts of
them on our input space. The given matrices are:-

Simulation Setup:-

●​ The input space is initialized using meshgrid.


●​ Transformations T6 and T7 are applied to input vectors.
●​ A total of four subplots are generated to systematically visualize the transformation
process:
1.​ Initial Input Space: Displays the original structured grid before any
transformations are applied.
2.​ After Applying T6: Shows the effect of applying transformation matrix T6, which
introduces a shear effect along the x-axis.
3.​ After Applying T7: Demonstrates the impact of T7, which performs a reflection
transformation along the y-axis.
4.​ After Sequential Application of T6 Followed by T7 (Composition of T6(T7)):
Illustrates the cumulative effect of applying T6 first and then T7, highlighting how
matrix composition alters the input space differently than individual
transformations.
●​ The subplot visualization enables a comparative study of how each transformation
individually and collectively modifies the original input space, reinforcing the concept of
matrix multiplication order in linear transformations.
●​ We have displayed these 4 graphs as subplots since a single plot for easier comparison
and also we have plotted a point on the plane to actually see the impact of the
transformation on the input space plot.
●​ The point I mentioned is(-1, 2).

MATLAB Code:-
x = [1; 0];
y = [0; 1];
[X, Y] = meshgrid(-2:1:3, -2:1:3);
T6 = [1, 1; 0, 1];
T7 = [-1, 0; 0, 1];
a=[-1;2];
a_new1=T6*a;
a_new2=T7*a;
a_new3=T7*a_new1;
x_t6 = T6 * x;
y_t6 = T6 * y;
X_T6 = x_t6(1) * X + y_t6(1) * Y;
Y_T6 = x_t6(2) * X + y_t6(2) * Y;
x_t7 = T7 * x;
y_t7 = T7 * y;
X_T7 = x_t7(1) * X + y_t7(1) * Y;
Y_T7 = x_t7(2) * X + y_t7(2) * Y;
x_t6_t7 = T7 * x_t6;
y_t6_t7 = T7 * y_t6;
X_T6_T7 = x_t6_t7(1) * X + y_t6_t7(1) * Y;
Y_T6_T7 = x_t6_t7(2) * X + y_t6_t7(2) * Y;
figure;
set(gcf, 'Position', [100, 100, 1400, 700]);
subplot(2, 2, 1);
hold on;
for i = 1:size(Y, 1)
plot(X(i, :), Y(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X(:, i), Y(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a(1),a(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('Original Input Space');
axis equal;
% After Applying T6
subplot(2, 2, 2);
hold on;

for i = 1:size(Y, 1)
plot(X_T6(i, :), Y_T6(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X_T6(:, i), Y_T6(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a_new1(1),a_new1(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('After Applying T6');
axis equal;
% After Applying T7
subplot(2, 2, 3);
hold on;
for i = 1:size(Y, 1)
plot(X_T7(i, :), Y_T7(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X_T7(:, i), Y_T7(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a_new2(1),a_new2(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('After Applying T7');
axis equal;
% After Applying T6 and T7
subplot(2, 2, 4);
hold on;
for i = 1:size(Y, 1)
plot(X_T6_T7(i, :), Y_T6_T7(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X_T6_T7(:, i), Y_T6_T7(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a_new3(1),a_new3(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('After Applying T6 and T7');
axis equal;
Results and Inference:-

●​ Effect of T6 (Shear Transformation): The transformation matrix T6 introduces a shear


effect along the x-axis. This means that every point in the input space is displaced
horizontally in proportion to its y-coordinate while maintaining its original y-position.
●​ Effect of T7 (Reflection Across the Y-Axis): The transformation matrix T7 reflects all
points across the y-axis. This means that every point on the right side of the y-axis is
mirrored onto the left side, and vice versa, effectively flipping the space horizontally.
●​ Combined Effect of T6 and T7 (Composition of Transformations): When T6 is
applied first, followed by T7, the input space undergoes both shear and reflection.
○​ First applying T6 shears the space, distorting the grid structure by shifting points
along the x-axis.
○​ Then applying T7 reflects the sheared space across the y-axis, further altering
the grid’s orientation and appearance.
●​ Non-Commutative Nature of Matrix Multiplication: The final transformed space
obtained by applying T6 first and then T7 differs from the space that would be obtained if
T7 were applied first, followed by T6. This confirms that matrix multiplication is not
commutative

Transformation Visualization:
Part 3: Transformation Analysis (Question 3)
Objective:-

To examine the effects of sequentially applying transformations T6 and T7 to the input space.
And also to examine the effect of applying their composition on the input space.

Transformation Matrices:-

The assignment provides us with two matrices T6 and T7 and we need to show the impacts of
them on our input space. The given matrices are:-

Simulation Setup:-

●​ The input space is initialized using MATLAB’s meshgrid function, generating a


structured grid from x = -2 to 3 and y = -2 to 3.
●​ The transformation matrices T8 and T9 are applied sequentially to visualize their
individual and combined effects on the input space.
●​ A total of four subplots are generated to systematically illustrate the transformation
process:
○​ Initial Input Space: Displays the original structured grid before any
transformation is applied.
○​ After Applying T8: Shows the effect of applying transformation matrix T8, which
combines rotation and scaling, altering both the orientation and spacing of points.
○​ After Applying T9: Demonstrates the impact of T9, which reflects the space
across the x-axis, flipping all points vertically.
○​ After Sequential Application of T8 Followed by T9 (Composition of T8(T9)):
Illustrates the cumulative effect of first applying T8, which rotates and scales the
space, and then T9, which performs reflection.
●​ The subplot visualization allows for easy comparison between the original input space
and its transformed versions. This helps in understanding how individual transformations
work and how their order influences the final result.
●​ To enhance clarity, we have displayed all four transformations as subplots within a
single figure for direct comparison.
●​ Additionally, a specific point (-1, 2) has been plotted on the plane to observe how
transformations affect a single coordinate in the input space. This provides a clearer
view of the geometric transformation effects beyond just the grid structure.
MATLAB Code:-

x = [1; 0];
y = [0; 1];
[X, Y] = meshgrid(-2:1:3, -2:1:3);
T8 = (1/sqrt(2))*[1, -1; 1, 1];
T9 = [1, 0; 0, -1];
a=[-1;2];
a_new1=T8*a;
a_new2=T9*a;
a_new3=T9*a_new1;
x_t8 = T8 * x;
y_t8 = T8 * y;
X_T8 = x_t8(1) * X + y_t8(1) * Y;
Y_T8 = x_t8(2) * X + y_t8(2) * Y;
x_t9 = T9 * x;
y_t9 = T9 * y;
X_T9 = x_t9(1) * X + y_t9(1) * Y;
Y_T9 = x_t9(2) * X + y_t9(2) * Y;
x_t8_t9 = T9 * x_t8;
y_t8_t9 = T9 * y_t8;
X_T8_T9 = x_t8_t9(1) * X + y_t8_t9(1) * Y;
Y_T8_T9 = x_t8_t9(2) * X + y_t8_t9(2) * Y;
figure;
set(gcf, 'Position', [100, 100, 1400, 700]);
subplot(2, 2, 1);
hold on;
for i = 1:size(Y, 1)
plot(X(i, :), Y(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X(:, i), Y(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a(1),a(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('Original Input Space');
axis equal;
% After Applying T8
subplot(2, 2, 2);
hold on;
for i = 1:size(Y, 1)
plot(X_T8(i, :), Y_T8(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X_T8(:, i), Y_T8(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a_new1(1),a_new1(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('After Applying T8');
axis equal;
% After Applying T9
subplot(2, 2, 3);
hold on;
for i = 1:size(Y, 1)
plot(X_T9(i, :), Y_T9(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X_T9(:, i), Y_T9(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a_new2(1),a_new2(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('After Applying T7');
axis equal;
% After Applying T8 then T9
subplot(2, 2, 4);
hold on;
for i = 1:size(Y, 1)
plot(X_T8_T9(i, :), Y_T8_T9(i, :), 'r-', 'LineWidth', 1.5);
end
for i = 1:size(X, 2)
plot(X_T8_T9(:, i), Y_T8_T9(:, i), 'b--', 'LineWidth', 1.5);
end
plot(a_new3(1),a_new3(2), 'ro', 'MarkerFaceColor', 'k');
hold off;
xlabel('X-axis');
ylabel('Y-axis');
title('After Applying T8 and T9');
axis equal;
Results and Inference:-

●​ Effect of T8 (Rotation and Scaling Transformation): The transformation matrix T8


applies a combination of rotation and scaling to the input space. It rotates all points
counterclockwise by 45 degrees while also scaling them by a factor of 1/sqrt(2)​. This
transformation distorts the original grid structure by changing both the orientation and
spacing between points while preserving straight-line relationships.
●​ Effect of T9 (Reflection Across the X-Axis): The transformation matrix T9 reflects all
points across the x-axis. This means that every point above the x-axis is flipped below,
and every point below the x-axis is flipped above while maintaining their x-coordinates.
The transformation mirrors the input space vertically without altering the horizontal
position of the points.
●​ Combined Effect of T8 and T9 (Composition of Transformations): When T8 is
applied first, followed by T9, the input space undergoes both rotation and reflection,
leading to a transformation that significantly alters the original grid structure:
●​ First applying T8 rotates and scales the input space, changing the positions of
grid lines and points.
●​ Then applying T9 reflects the rotated and scaled space across the x-axis,
flipping all points vertically while retaining their transformed horizontal positions.
●​ Non-Commutative Nature of Matrix Multiplication: The final transformed space
obtained by applying T8 first and then T9 differs from the space that would result if T9
were applied first, followed by T8. This confirms that matrix multiplication is not
commutative, meaning that the order in which transformations are applied significantly
impacts the final outcome.

Transformation T8 and T9 Visualization:

(In place of T7 it would be T9 in the 3rd subplot)


Conclusion:-
●​ Impact of Linear Transformations on Input Space:
○​ Linear transformations have a significant effect on the structure of the input
space by modifying its geometric properties.
○​ Depending on the transformation matrix used, the space can undergo stretching,
shrinking, shearing, rotation, or reflection.
○​ These transformations allow for the manipulation of spatial structures, which is
essential in applications such as image processing, physics simulations, and
machine learning.
●​ Importance of Matrix Multiplication Order:
○​ The order in which matrices are multiplied determines the final transformation
outcome.
○​ Since matrix multiplication is not commutative, applying transformations in
different sequences results in distinct spatial modifications.
○​ This property is crucial in practical applications, such as computer graphics and
robotics, where transformation sequences affect object positioning and motion.
●​ Role of MATLAB in Visualization:
○​ MATLAB provides a powerful platform for implementing and visualizing linear
transformations in a structured and interactive manner.
○​ The ability to generate structured grids and apply transformations step by step
allows for a deeper understanding of how each matrix affects the input space.
○​ MATLAB’s visualization tools help bridge the gap between theoretical linear
algebra concepts and real-world applications, making abstract transformations
more intuitive and accessible.

You might also like