フィルターのクリア

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

1 回表示 (過去 30 日間)
Surendra Ratnu
Surendra Ratnu 2023 年 4 月 30 日
コメント済み: Star Strider 2023 年 5 月 3 日
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 件のコメント
Surendra Ratnu
Surendra Ratnu 2023 年 5 月 3 日
ok thank you for your help
Star Strider
Star Strider 2023 年 5 月 3 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface 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