Draw arc with specified angle difference
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
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
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개)
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)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!