Grab polar intersection point coordinates from a plot

4 vues (au cours des 30 derniers jours)
Lorenzo Lellini
Lorenzo Lellini le 22 Déc 2022
Commenté : Star Strider le 24 Déc 2022
This code that plots a certain amount of circumferences and radiuses (separated by a given angle).
I need to find all the interesection points coordinates between radius and circumferences in polar and cartesian coordinates.
I should create vectors to store all the intersection coordinates for each radius.
Have you any idea about what I can do?
clear all
close all
clc
R=50; %circ radius
S=20; %num circ.lines
N=16; %num ang.lines
sect_width=2*pi/N;
sections_angle = rad2deg(sect_width);
offset_angle=0:sect_width:2*pi-sect_width;
%------------------
r=linspace(0,R,S+1);
w=0:.01:2*pi;
figure(1)
hold on
axis equal
grid minor
% plot circumferences
for n=2:length(r)
plot(real(r(n)*exp(1i*w)),imag(r(n)*exp(1i*w)),'k')
end
% plot radius
for n=1:length(offset_angle)
plot(real([0 R]*exp(1i*offset_angle(n))),imag([0 R]*exp(1i*offset_angle(n))),'k', 'LineWidth',1.2)
end

Réponse acceptée

Star Strider
Star Strider le 23 Déc 2022
The intersections can be calculated directly from the information provided in the code.
Creating a table of them in Cartesian and polar coordinates is then straightforward —
R=50; %circ radius
S=20; %num circ.lines
N=16; %num ang.lines
sect_width=2*pi/N;
sections_angle = rad2deg(sect_width);
offset_angle=0:sect_width:2*pi-sect_width;
%------------------
r=linspace(0,R,S+1);
w=0:.01:2*pi;
figure(1)
hold on
axis equal
grid minor
% plot circumferences
for n=2:length(r)
plot(real(r(n)*exp(1i*w)),imag(r(n)*exp(1i*w)),'k')
end
% plot radius
for n=1:length(offset_angle)
plot(real([0 R]*exp(1i*offset_angle(n))),imag([0 R]*exp(1i*offset_angle(n))),'k', 'LineWidth',1.2)
end
xisx = r(:)*cos(offset_angle); % X-Coordinates Of Intersections
yisx = r(:)*sin(offset_angle); % Y-Coordinates Of Intersections
plot(xisx, yisx, 'sg', 'MarkerSize', 3, 'MarkerFaceColor','g') % Plot Intersections (Cartesian)
hold off
[angisx,radisx] = cart2pol(xisx, yisx); % Polar Coordinates Of Interseections
Intersections = table(xisx(:), yisx(:), angisx(:), radisx(:), 'VariableNames',{'X','Y','Angle','Radius'})
Intersections = 336×4 table
X Y Angle Radius ____ _ _____ ______ 0 0 0 0 2.5 0 0 2.5 5 0 0 5 7.5 0 0 7.5 10 0 0 10 12.5 0 0 12.5 15 0 0 15 17.5 0 0 17.5 20 0 0 20 22.5 0 0 22.5 25 0 0 25 27.5 0 0 27.5 30 0 0 30 32.5 0 0 32.5 35 0 0 35 37.5 0 0 37.5
.
  2 commentaires
Lorenzo Lellini
Lorenzo Lellini le 24 Déc 2022
Thank you! Very useful
Star Strider
Star Strider le 24 Déc 2022
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by