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

6 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Star Strider
Star Strider el 30 de Abr. de 2023
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 comentarios
Surendra Ratnu
Surendra Ratnu el 3 de Mayo de 2023
ok thank you for your help
Star Strider
Star Strider el 3 de Mayo de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image display and manipulation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by