How to find angle between a fixed point to multiple point ??

1 次查看(过去 30 天)
I would like to calculate the angle ABC which is shown in the figure. I have fixed line AB and multiple point on the boundary-1 (in red colour). I want to calculate a array of angle between line AB and BC (C is a moving point is on the boundary-1) and also corresponding distance from point C to nearest point on the boundary-2(in green colour). I attached a figure for clearification and boundaries mat file.
Thank you for your help

采纳的回答

Star Strider
Star Strider 2023-4-30
Perhaps this —
M = load('M.mat');
M = M.M;
N = load('N.mat');
N = N.N;
xv = 506; % Determined Manually
yv = 119; % Determined Manually
a = atan2d(M(:,2)-yv, M(:,1)-xv); % Angles (°)
d = hypot(yv-M(:,2), xv-M(:,1)); % Distances
v = (1:210:size(M,1)).'; % Selection Vector For Plot
figure
plot(N(:,1), N(:,2),'g')
hold on
plot(M(:,1), M(:,2),'r')
plot([xv*ones(size(v)) M(v,1)].', [yv*ones(size(v)) M(v,2)].', '--m')
plot(506, 119,'k+')
yl = ylim;
plot([1 1]*506, [yl(1) 119], '-k')
hold off
grid
Ax = gca;
% Ax.YDir = 'reverse';
axis('equal')
text(M(v,1), M(v,2), compose('\\leftarrow r = %.2f, \\theta = %.2f\\circ', [d(v) a(v)]), 'Rotation',0)
The angles make more sense with a normal y-axis direction. Un-comment the ‘YDir’ assignment to show it as in the original image.
.
  6 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by