How to find angle between a fixed point to multiple point ??
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Surendra Ratnu
le 30 Avr 2023
Commenté : Star Strider
le 3 Mai 2023
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
0 commentaires
Réponse acceptée
Star Strider
le 30 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!