Draw arc with specified angle difference
    14 views (last 30 days)
  
       Show older comments
    
    Elysi Cochin
      
 on 9 Jun 2021
  
    
    
    
    
    Commented: Star Strider
      
      
 on 10 Jun 2021
            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 Comments
Accepted Answer
  Star Strider
      
      
 on 9 Jun 2021
        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 Comments
  Star Strider
      
      
 on 10 Jun 2021
				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.
More Answers (2)
  darova
      
      
 on 9 Jun 2021
        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)
See Also
Categories
				Find more on Operating on Diagonal Matrices in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



