Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
0 views

random

The DS-412 Lab Report by Nitin Chaurasiya focuses on exploring linear transformations through MATLAB simulations, emphasizing their sequential effects on geometrical structures in vector spaces. The report details the setup, algorithms, and visualization techniques used to apply and analyze transformations, including shearing, reflection, and rotation. Results are presented with clear figures and explanations, highlighting the importance of transformation order and the impact of individual versus composite transformations.

Uploaded by

robbinsonmaddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

random

The DS-412 Lab Report by Nitin Chaurasiya focuses on exploring linear transformations through MATLAB simulations, emphasizing their sequential effects on geometrical structures in vector spaces. The report details the setup, algorithms, and visualization techniques used to apply and analyze transformations, including shearing, reflection, and rotation. Results are presented with clear figures and explanations, highlighting the importance of transformation order and the impact of individual versus composite transformations.

Uploaded by

robbinsonmaddy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

DS-412 Lab Report

Name: Nitin Chaurasiya


Roll No.: B23220
Branch: Data Science
Date: 23-03-2025

Linear Transformations Lab - (II)


(DS412)

Lab Assignment # 3

Indian Institute of Technology Mandi, HP, India


School of Computing and Electrical Engineering (SCEE)
DS412 LAB REPORT 3 Page 1 of 12

Linear Transformations

Objective
The primary goal of this lab is to explore compositions of linear transformations in and
understand their sequential effects through visualization. By applying two linear trans-
formations sequentially and analyzing their composition, we develop an intuition about
how these transformations alter geometrical structures in vector spaces.

1 Setup
This section explains the algorithm, the simulation setup, and the syntax of the key
MATLAB functions used to implement and visualize compositions of linear transforma-
tions.

1.1 Algorithm
The algorithm involves applying linear transformations sequentially on an input vector
space R2 and visualizing the effects.

1. Define the Input Space


• Create a 2D grid of points over the range [−2, 3] for both x and y axes.
• Plot the horizontal and vertical grid lines that represent the structure of
the space before transformation.
2. Define Transformation Matrices
• Two sets of transformations are applied:
– Q1 Transformations:
   
1 1 −1 0
T6 = , T7 =
0 1 0 1
– Q2 Transformations:
   
1 1 −1 1 0
T8 = √ , T9 =
2 1 1 0 −1
3. Apply the Transformations
• Perform matrix multiplication between the transformation matrix and the grid
points.
• For a point (x, y), the transformation is computed as:
   
xnew x
=T×
ynew y
DS412 LAB REPORT 3 Page 2 of 12

• Apply transformations sequentially and plot the results after each stage.

4. Visualization

• Plot the grids after each transformation to compare the effects:


– Original input space
– After the first transformation
– After the second transformation
– After the composition of both transformations
• Use different line styles and colors for clarity.

1.2 Explanation of the Setup


The setup consists of the following components:

1. Input Grid Generation


We generate a grid of points using MATLAB’s meshgrid() function to represent
the vector space.

2. Grid Lines Creation


Each row of the grid represents a horizontal line, and each column represents a
vertical line. We transform these lines using matrix multiplication.

3. Transformation Matrices
We apply the given transformation matrices individually and in sequence (compo-
sition).

4. Plotting Strategy
The visualizations are created using MATLAB’s plotting functions:

• Horizontal lines are plotted as solid red lines.


• Vertical lines are plotted as dashed blue lines.

5. Subplots
Subplots are used to display different stages of transformation within a single figure
for easy comparison.

1.3 Explanation / Syntax of Key MATLAB Functions Used


1.4 Transformation Application Example in MATLAB
For a single horizontal line:
% Select a row of points for a horizontal line
X_row = X(i, :);
Y_row = Y(i, :);

% Apply transformation matrix T to each point


new_points = T * [X_row; Y_row];
DS412 LAB REPORT 3 Page 3 of 12

Function Purpose Syntax / Example


meshgrid() Generates a grid of x and y [X, Y] = meshgrid(x range,
points for vector space rep- y range);
resentation. Example: [X, Y] =
meshgrid(-2:1:3, -2:1:3);
plot() Plots lines between points plot(X row, Y row, ’r-’);
(horizontal or vertical grid (for horizontal lines)
lines). plot(X col, Y col, ’b--’);
(for vertical lines)
hold on Allows multiple plots on the hold on;
same figure without over-
writing previous plots.
axis equal Ensures both axes use the axis equal;
same scale, preserving geo-
metric accuracy.
title() Adds a title to each plot or title(’Input Space’);
subplot.
subplot() Creates multiple plots in a subplot(rows, columns,
single figure window. plot number);
Example: subplot(2, 2, 1);
Matrix Multipli- Applies transformation to [new X; new Y] = T * [X row;
cation each line in the grid (vector- Y row];
ized).

Table 1: Key MATLAB functions used in the setup

% Extract new X and Y


new_X_row = new_points(1, :);
new_Y_row = new_points(2, :);

% Plot the transformed horizontal line


plot(new_X_row, new_Y_row, ’r-’);

For a single vertical line:

% Select a column of points for a vertical line


X_col = X(:, j);
Y_col = Y(:, j);

% Apply transformation matrix T to each point


new_points = T * [X_col’; Y_col’]; % Transpose because of MATLAB conventions

% Extract new X and Y


new_X_col = new_points(1, :);
new_Y_col = new_points(2, :);
DS412 LAB REPORT 3 Page 4 of 12

% Plot the transformed vertical line


plot(new_X_col, new_Y_col, ’b--’);

1.5 Flow of the MATLAB Code for Setup (Overview)


1. Initialize input space limits:

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

2. Plot the original input space grid.

3. Define transformation matrices (T6, T7, T8, T9).

4. Loop through each row and column of the grid:

• Apply transformation
• Plot transformed lines

5. Create subplots for:

• Original input space


• After T6 / T8
• After T7 / T9
• After T7 ◦ T6 / T9 ◦ T8

1.6 Summary
The setup uses matrix multiplication to apply linear transformations to a grid rep-
resenting the vector space. MATLAB functions like meshgrid(), plot(), and subplot()
make visualization clear and intuitive. The sequence of transformations and their effects
are displayed in multiple subplots for easy comparison and interpretation.

2 Results
This section showcases the outcomes derived from implementing and visualizing composi-
tions of linear transformations on a two-dimensional input space. Each transformation is
applied in sequence, with the resulting grids displayed. The accuracy of these transforma-
tions is confirmed through visual validation of their geometric effects, including shearing,
reflection, and rotation. Each figure is distinctly labeled to emphasize the transformations
and their impact.
DS412 LAB REPORT 3 Page 5 of 12

2.1 Figures Rendering, Accuracy, Labeling, and Explanation


2.1.1 Input Space Plot (Figure 1)

Figure 1: Input Space Grid (Original)

Rendering:
The input space is represented by a grid covering [−2, 3] on both x and y axes. Horizontal
lines are shown as solid red lines and vertical lines as dashed blue lines.
Labeling:

• Title: Input Space (Original Grid).


• X-axis and Y-axis are labeled appropriately.
Explanation:
This serves as the baseline for all transformations. It represents an orthogonal basis
before applying any linear transformation.

2.1.2 Q1 Transformations (Figures 2-4)

Figure 2: After Applying T6 (Shear Transformation)

Figure 2: After Applying T6 (Shear Transformation) Rendering:


Grid lines have been sheared along the x-axis. Vertical lines are slanted due to the
shearing effect, while horizontal lines remain parallel.
DS412 LAB REPORT 3 Page 6 of 12

Labeling:

• Title: After Applying T6 (Shear Transformation).

• Axes are labeled, and colors are consistent (red for horizontal, blue for vertical).

Explanation:
The matrix T6 shears the grid:  
1 1
T6 =
0 1
This results in xnew = x + y and ynew = y. The grid is accurately transformed as expected
from a shear transformation.

Figure 3: After Applying T7 on T6 (Reflection Across Y-axis)

Figure 3: After Applying T7 on T6 (Reflection Across Y-axis) Rendering:


The sheared grid is now reflected across the y-axis. The previously right-oriented shear
becomes left-oriented due to the reflection.
Labeling:

• Title: After Applying T7 on T6 (Reflection Across Y-axis).

• Axes are labeled for clarity.

Explanation:
T7 reflects the grid horizontally:  
−1 0
T7 =
0 1
xnew = −x, flipping the sheared grid. The transformation has been verified to reflect the
geometry as expected.
DS412 LAB REPORT 3 Page 7 of 12

Figure 4: Composition of T7 and T6 (T7 ◦ T6 )

Figure 4: Composition T7 ◦ T6 Rendering:


This plot directly applies the composition T7 ◦ T6 . The grid is sheared and then reflected
in one combined operation.
Labeling:

• Title: Composition of T7 and T6 (T7 ◦ T6 ).

• Axes labeled for reference.


Explanation:
The composed matrix is:  
−1 −1
T7 ◦ T6 = T7 T6 =
0 1
This combines the shear and reflection, resulting in a mirrored shear grid, consistent with
sequential application.

2.1.3 Q2 Transformations (Figures 5-7)

Figure 5: After Applying T8 (Rotation + Scaling)

Figure 5: After Applying T8 (Rotation and √ Scaling) Rendering:


The input grid is rotated by 45° and scaled by 1/ 2. The axes now align diagonally.
DS412 LAB REPORT 3 Page 8 of 12

Labeling:

• Title: After Applying T8 (Rotation + Scaling).

• Axes labeled appropriately.

Explanation:
The transformation matrix T8 is:
 
1 1 −1
T8 = √
2 1 1

It rotates the space by 45° and scales by 1/ 2. The grid spacing and angles confirm the
transformation accuracy.

Figure 6: After Applying T9 on T8 (Reflection Across X-axis)

Figure 6: After Applying T9 on T8 (Reflection Across X-axis) Rendering:


The rotated and scaled grid from T8 is now reflected across the x-axis by T9 . The trans-
formed grid shows symmetry across the x-axis.
Labeling:

• Title: After Applying T9 on T8 (Reflection Across X-axis).

• Axes are labeled for clarity.

Explanation:
T9 reflects across the x-axis:  
1 0
T9 =
0 −1
It flips y values to −y, producing a vertically mirrored grid of the rotated structure.
DS412 LAB REPORT 3 Page 9 of 12

Figure 7: Composition of T9 and T8 (T9 ◦ T8 )

Figure 7: Composition T9 ◦ T8 Rendering:


This plot directly applies the composition T9 ◦ T8 to the input space. It combines rotation
+ scaling followed by reflection across the x-axis.
Labeling:

• Title: Composition of T9 and T8 (T9 ◦ T8 ).


• Axes labeled clearly.
Explanation:
The composed transformation matrix is:
 
1 1 −1
T9 ◦ T8 = T9 T8 = √
2 −1 −1
The plot confirms the result of rotating + scaling and then reflecting, consistent with
sequential operations.

2.2 Accuracy Verification


The transformations have been applied according to linear algebra principles (matrix
multiplication). The rendered figures accurately reflect the following:
• Shearing: Verified by slanted grid lines.
• Reflection: Verified by flipped orientation along axes.
• Rotation and Scaling: Verified by diagonal alignment and uniform scaling.

2.3 Labeling Consistency


• All figures include descriptive titles.
• Axes are clearly labeled.
• Consistent color schemes are used:
– Red solid lines: Horizontal grid lines.
– Blue dashed lines: Vertical grid lines.
DS412 LAB REPORT 3 Page 10 of 12

2.4 Summary of Results

Figure Description
1 Input space grid (Original)
2 After applying T6 (Shear transformation)
3 After applying T7 on T6 (Reflection after Shear)
4 Composition T7 ◦ T6 (Shear + Reflection)
5 After applying T8 (Rotation + Scaling)
6 After applying T9 on T8 (Reflection after Rotation)
7 Composition T9 ◦ T8 (Rotation + Scaling + Reflection)

Table 2: Summary of Figures and Their Descriptions

3 Inferences
This section presents the logical interpretations, insights, and key learnings derived from
the implementation and visualization of compositions of linear transformations in the
two-dimensional space R2 . By analyzing the results from both sets of transformation
matrices (T6 , T7 for Q1 and T8 , T9 for Q2), we gain a deeper understanding of how
sequential linear transformations affect the geometry of vector spaces.

3.1 Logical Interpretation


1. Order of Transformations Matters
The experiments clearly demonstrate that the order in which linear transformations
are applied has a significant impact on the final outcome. For example:
• Applying T6 followed by T7 (Q1) results in a sheared and then reflected space.
• Reversing the order (T7 followed by T6 ), which was not explicitly visualized
in this lab, would lead to a different geometrical effect, emphasizing the non-
commutative property of matrix multiplication.
2. Individual vs. Composite Transformations
Visualizing each transformation separately and then as a composition helps in un-
derstanding how individual transformations contribute to the overall effect:
• T6 introduces a shear along the x-axis, while T7 reflects the points along the
y-axis.
• Their combination (T7 ◦ T6 ) achieves a mirrored shear, which would have been
difficult to predict without visualization.
3. Preservation and Alteration of Geometric Properties
Different linear transformations preserve or alter different geometric properties:
• Shear (T6 ): Preserves area but alters angles.
• Reflection (T7 , T9 ): Preserves angles and distances but changes orientation.
• Rotation and Scaling (T8 ): Preserves angles (up to scaling) and rotates the
entire space around the origin.
DS412 LAB REPORT 3 Page 11 of 12

3.2 Insights
• Visualization Enhances Understanding
Visualizing transformations offers a clearer perspective on the abstract algebraic
process of matrix multiplication. It helps in intuitively understanding how opera-
tions like shear, reflection, rotation, and scaling alter the spatial arrangement of a
grid.
• Linear Transformations as Tools for Space Manipulation
This lab strengthens the concept that linear transformations provide a systematic
way to modify spaces. Whether through compression, stretching, rotation, or re-
flection, selecting appropriate transformation matrices enables precise control over
vector space geometry, with applications in computer graphics, machine learning
(feature space transformations), and robotics (coordinate adjustments).
• Composability of Transformations
Intricate transformations can be built by combining simpler ones. Grasping how
multiple transformations interact is crucial for anticipating and managing the final
outcome, with practical applications in fields like 3D modeling, physics simulations,
and data processing pipelines.
• Geometric Interpretations of Matrices
Each matrix represents a geometric action:
– T6 (Shear): Moves points parallel to one axis.
– T7 (Reflection): Flips points across an axis.
– T8 (Rotation + Scaling): Rotates points while changing their magnitude.
– T9 (Reflection): Reflects points across an axis.
These interpretations help in mentally visualizing the effects of matrices without
needing to perform matrix multiplication by hand.

3.3 Learnings from the Lab and Results


1. Practical Application of Linear Algebra Concepts
The lab offered practical experience in utilizing linear algebra principles, partic-
ularly matrix multiplication, for real-world geometric transformations. Observing
the effects visually helped strengthen the theoretical understanding.
2. Importance of Matrix Multiplication Order
The non-commutative property of matrix multiplication was evident from the vari-
ations seen in individual and composite transformation plots. This is a key realiza-
tion for domains where the sequence of operations influences the final result, such
as computer graphics and transformations in physics.
3. Use of MATLAB for Visualization
MATLAB demonstrated its effectiveness in implementing and visualizing transfor-
mations. Functions such as meshgrid(), plot(), and various matrix operations
played a crucial role in producing precise graphical representations of the transfor-
mation.
DS412 LAB REPORT 3 Page 12 of 12

4. Concept of Basis Change and Space Deformation


Transformations like rotation, shear, and reflection can be interpreted as modifying
the basis vectors of a space. This perspective aids in grasping more advanced
concepts such as eigenvectors, eigenspaces, and diagonalization.

3.4 Conclusion
In conclusion this lab provided deeper insights into the practical workings of linear trans-
formation compositions. By analyzing the graphical impact of individual transformations
and their combinations, we developed a stronger intuition about how linear transforma-
tions alter vector spaces. The concepts explored in this lab serve as a solid groundwork for
more advanced topics in linear algebra and its applications across data science, machine
learning, computer graphics, and physics.
.

You might also like