can any body find the mistake here? I am rotating the coordinates of the arc and then bringing it to its original position. but it is not coming back to its original position ????!!!!

1 view (last 30 days)
clear, clc
% the arc coordinates
a=2:0.001:3;
b=sqrt((16-a.^2));
plot(a,b,'k')
axis equal
grid on
hold on
% the new coordinate axis origin and rotating angle from the first
% coordinate
x_origin= 1;
y_origin= 1;
rot_angle= -45;
% 1- calculating the coordinate of the arc according to the new coordinates
% translating
a11=a-x_origin;
b11=b-y_origin;
% rotating
a1=a.*cosd(-1*rot_angle)-b.*sind(-1*rot_angle);
b1=a.*sind(-1*rot_angle)+b.*cosd(-1*rot_angle);
plot(a1,b1,'r')
% 2- re_transformating the axis to the first one
% rotating
a22=a1.*cosd(rot_angle)-b1.*sind(rot_angle);
b22=a1.*sind(rot_angle)+b1.*cosd(rot_angle);
% translating
a2=a22+x_origin;
b2=b22+y_origin;
plot(a2,b2,'--g')
Capture.PNG

Accepted Answer

Matt J
Matt J on 18 Jun 2019
Edited: Matt J on 18 Jun 2019
Some observations,
  1. You never use a11,b11 anywhere.
  2. After rotating back, you perform a translation by x_origin, y_origin. In other words, it did come back to its original position, but then you shifted it.
  1 Comment
nezir elali
nezir elali on 19 Jun 2019
Dear Matt j
thanks for your answer.
I noticed that after I submitted the question ..... when I was very sleepy and tired ..... and barely I could hold my eyes open..... really, I solved this small problem ..... here is the codes:
clear, clc
% the main arc coordinates
a=2:0.001:3;
b=sqrt((16-a.^2));
plot(a,b,'k')
axis equal
grid on
hold on
% the new coordinate axis origin and rotating angle from the first
% coordinate
x_origin= 1;
y_origin= 1;
rot_angle= -45;
% 1- calculating the coordinate of the arc according to the new coordinates
% translating
a11=a-x_origin;
b11=b-y_origin;
% rotating
a1=a11.*cosd(-1*rot_angle)-b11.*sind(-1*rot_angle);
b1=a11.*sind(-1*rot_angle)+b11.*cosd(-1*rot_angle);
plot(a1,b1,'r')
% 2- re_transformating the axis to the first one
% rotating
a22=a1.*cosd(rot_angle)-b1.*sind(rot_angle);
b22=a1.*sind(rot_angle)+b1.*cosd(rot_angle);
% translating
a2=a22+x_origin;
b2=b22+y_origin;
plot(a2,b2,'o')

Sign in to comment.

More Answers (0)

Categories

Find more on Polar Plots in Help Center and File Exchange

Tags

Products


Release

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!