Lab Report (Linear Transformations (II) )
Lab Report (Linear Transformations (II) )
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.
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:-
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;
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:-
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:-
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:-
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:-