Grab polar intersection point coordinates from a plot

2 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2022-12-23
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
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polar Plots 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by