Draw arc with specified angle difference

조회 수: 1(최근 30일)
Elysi Cochin
Elysi Cochin 2021년 6월 9일
댓글: Star Strider 2021년 6월 10일
Having 2 datas as attached in Data.mat, how to draw arc with a specified angle difference (angle difference can vary say 15, 30 or any other value as given by user)
The data columns in order are angle, radius, depth
How can i find the center with the attached data, so that both the arcs pass through the center, and display it in x,y,z coordinate
  댓글 수: 3
Elysi Cochin
Elysi Cochin 2021년 6월 9일
Sir, can you show me how to plot, if the angles are radian values (descending spiral)

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2021년 6월 9일
Try this —
LD = load('Data.mat');
Data1 = LD.Data1;
A1 = Data1(:,1);
R1 = Data1(:,2);
D1 = Data1(:,3);
Data2 = LD.Data2;
A2 = Data2(:,1);
R2 = Data2(:,2);
D2 = Data2(:,3);
ctrfcn = @(b,a,r,d) [sqrt((b(1)+r.*cosd(a)).^2 + (b(2)+r.*sind(a)).^2 + (b(3)-d).^2)];
[B1,fval] = fminsearch(@(b)norm(ctrfcn(b,A1,R1,D1)), -rand(3,1)*1E+4)
[B2,fval] = fminsearch(@(b)norm(ctrfcn(b,A2,R2,D2)), -rand(3,1)*1E+4)
figure
plot3(R1.*cosd(A1), R1.*sind(A1), D1, 'm')
hold on
plot3(R2.*cosd(A2), R2.*sind(A2), D2, 'c')
scatter3(B1(1), B1(2), B1(3), 30, 'm', 'p', 'filled')
scatter3(B2(1), B2(2), B2(3), 30, 'c', 'p', 'filled')
hold off
legend('Data_1','Data_2', 'Centre_1', 'Centre_2', 'Location','best')
grid on
The axes are not scaled to be equal, because it then appears to be a flat surface.
Data1 Center:
x = -740.85
y = -349.01
z = 3.83
Data2 Center:
x = -740.96
y = -348.77
z = 3.81
.
  댓글 수: 5
Star Strider
Star Strider 2021년 6월 10일
As a general rule when talking about arcs or circles, the center is the center of the circle. It can never be on any of the circumferences.
You are asking for the midpoint of the arc.
MP1 = median([R1.*cosd(A1)+B1(1), R1.*sind(A1)+B1(2), D1],1);
MP2 = median([R2.*cosd(A2)+B2(1), R2.*sind(A2)+B2(2), D2],1);
fprintf(1,'Arc Midpoint 1:\n\t\tx = %8.2f\n\t\ty = %8.2f\n\t\tz = %8.2f\n',MP1)
fprintf(1,'Arc Midpoint 2:\n\t\tx = %8.2f\n\t\ty = %8.2f\n\t\tz = %8.2f\n',MP2)
produces —
Arc Midpoint 1:
x = 745.33
y = 366.43
z = 3.83
Arc Midpoint 2:
x = 752.68
y = 364.83
z = 3.82
That is the best I can do.

댓글을 달려면 로그인하십시오.

추가 답변(2개)

Image Analyst
Image Analyst 2021년 6월 9일
  댓글 수: 1
Elysi Cochin
Elysi Cochin 2021년 6월 9일
Sir, i saw that link, but the data I have, is different with the example shown in the link.

댓글을 달려면 로그인하십시오.


darova
darova 2021년 6월 9일
Wha about this representation?
s = load('data.mat');
t = linspace(0,1,20)*pi/180; % angle array
[X,Y,Z] = deal( zeros(10,20) ); % preallocation matrices
for i = 1:10
[X(i,:),Y(i,:)] = pol2cart(t*s.Data1(i,1),s.Data1(i,2)); % create arc
Z(i,:) = s.Data1(i,3); % depth
end
surf(X,Y,Z)
  댓글 수: 1
Elysi Cochin
Elysi Cochin 2021년 6월 9일
편집: Elysi Cochin 2021년 6월 9일
Sir how to convert the radius value from degrees to radians and plot the figure
also, at a time i want to give only one angle

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by