clear all
Explanation
Remove items from MATLAB
workspace and reset MuPAD engine
clc
Clear Command Window
program
k =input('enter the value of shear factor');
dx =input('enter the value of translation in x');
dy =input('enter the value of translation in y');
m=input('enter the number of vetices');
n=2;
m=m+1;
for i=1:n
for j=1:m
pts(i,j) =input('enter the element roewise');
end
end
[n m] = size(pts);
figure(1)
plot(pts(1,1:end),pts(2,1:end),'b*-');
shear = [1 k;0 1];
rot = [cos(-45) sin(-45);-sin(-45) cos(-45)];
trans = [1 0 dx;0 1 dy; 0 0 1];
homogeneous_shear = eye(3);
homogeneous_shear(1:2,1:2) = shear;
homogeneous_rot = eye(3);
homogeneous_rot(1:2,1:2) = rot;
homogeneous_pts = [pts; ones(1,5)];
trans_pts =
trans*homogeneous_shear*homogeneous_pts;
This is input data mention in the
problem statement. After running
the program it will ask the values
of k, dx, dy, m, and x y
coordinates.
Figure (1) is the plot window for
output
Plot command for plotting initial
given entity
Define the shear , rotation and
translation matrix
Converting the shear and rotation
matrix in homogeneous form
According to the entity the
number will change if triangle
then it will be (1,4)
And if rectangle then (1,5).
By using composite transformation
matrix find the new coordinates
hold on
plot(trans_pts(1,1:end),trans_pts(2,1:end),'r*-');
hold on is for plotting the new
coordinates in previous figure plot
window
Command window appears
enter the value of shear factor3
enter the value of translation in x3
enter the value of translation in y5
enter the value of shear factor
enter the value of translation in x
enter the value of translation in y
enter the number of vetices3
enter the number of vetices
enter
enter
enter
enter
enter
the
the
the
the
the
element
element
element
element
element
roewise0
roewise5
roewise5
roewise0
roewise0
enter the element
enter the element
enter the element
enter the element
enter the element
Plot output
roewise0
roewise0
roewise3
roewise3
roewise0
enter the X coordinates of all vertices
in clockwise direction
enter the Y coordinates of all vertices
in clockwise direction
We will get output plot
7
6
5
4
3
2
1
0
10
12
14
16
18