Moving Sets of Random Data in a 2D Plane
clc
clear
M=100;
% N=10;
% LX=100;
% LY=100;
% dx=LX/M;
% dy=LY/N;
x1=100;
y1=100;
for i=1:M;
x(i)=100*rand(1,1)+x1;
y(i)=100*rand(1,1)+y1;
vect1(i,1:2)=[ x(i) y(i) ];
end
plot(x,y,'*')
grid on
hold on
x0=0;
y0=0;
plot(x0,y0,'*r');
xc=sum(x)/M;
yc=sum(y)/M;
plot(xc,yc,'*r');
for i=1:M;
xx(i)=x(i)-xc;
yy(i)=y(i)-yc;
end
plot(xx,yy,'*g')
title('Offseting a set of points')
xlabel('x')
ylabel('y')
% clc
% clear
% %Number of points
% N=5;
%coordinates of coordinate system
x(1)=0;
y(1)=0;
% %Generating the random set of points
% for i=2:N;
% x(i)=rand(1,1);
% y(i)=rand(1,1);
% end
% plot(x(2:N),y(2:N),'-*')
% grid on
%Mirroring Angle around y axis
deg1=90;
th1=(pi/180)*deg1;
%Mirroring Angle around x axis
deg2=deg1;
th2=(pi/180)*deg2;
%The point rotation section
for i=2:M;
theta(i)=atan((y(i)-y(1))/(x(i)-x(1)));
r(i)=(x(i)-x(1))/cos(theta(i));
xx(i)=r(i)*cos(theta(i)+th1)+x(1);
%r(i)=(y(i)-y(1))/sin(theta(i));
yy(i)=r(i)*sin(theta(i)+th2)+y(1);
end
% hold on
plot(xx(2:M),yy(2:M),'*r')
title('Mirroring around the y or x axis of a random set of data')
xlabel('x')
ylabel('y')
%legned('orginal','mirrored')
axis equal
plot(x(1),y(1),'*r');
hold off
clear
M=100;
% N=10;
% LX=100;
% LY=100;
% dx=LX/M;
% dy=LY/N;
x1=100;
y1=100;
for i=1:M;
x(i)=100*rand(1,1)+x1;
y(i)=100*rand(1,1)+y1;
vect1(i,1:2)=[ x(i) y(i) ];
end
plot(x,y,'*')
grid on
hold on
x0=0;
y0=0;
plot(x0,y0,'*r');
xc=sum(x)/M;
yc=sum(y)/M;
plot(xc,yc,'*r');
for i=1:M;
xx(i)=x(i)-xc;
yy(i)=y(i)-yc;
end
plot(xx,yy,'*g')
title('Offseting a set of points')
xlabel('x')
ylabel('y')
% clc
% clear
% %Number of points
% N=5;
%coordinates of coordinate system
x(1)=0;
y(1)=0;
% %Generating the random set of points
% for i=2:N;
% x(i)=rand(1,1);
% y(i)=rand(1,1);
% end
% plot(x(2:N),y(2:N),'-*')
% grid on
%Mirroring Angle around y axis
deg1=90;
th1=(pi/180)*deg1;
%Mirroring Angle around x axis
deg2=deg1;
th2=(pi/180)*deg2;
%The point rotation section
for i=2:M;
theta(i)=atan((y(i)-y(1))/(x(i)-x(1)));
r(i)=(x(i)-x(1))/cos(theta(i));
xx(i)=r(i)*cos(theta(i)+th1)+x(1);
%r(i)=(y(i)-y(1))/sin(theta(i));
yy(i)=r(i)*sin(theta(i)+th2)+y(1);
end
% hold on
plot(xx(2:M),yy(2:M),'*r')
title('Mirroring around the y or x axis of a random set of data')
xlabel('x')
ylabel('y')
%legned('orginal','mirrored')
axis equal
plot(x(1),y(1),'*r');
hold off
Unless otherwise noted, all content on this site is @Copyright by Ahmed Al Makky 2012-2013 - http://cfd2012.com