フィルターのクリア

Grab polar intersection point coordinates from a plot

2 ビュー (過去 30 日間)
Lorenzo Lellini
Lorenzo Lellini 2022 年 12 月 22 日
コメント済み: Star Strider 2022 年 12 月 24 日
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
.
  2 件のコメント
Lorenzo Lellini
Lorenzo Lellini 2022 年 12 月 24 日
Thank you! Very useful
Star Strider
Star Strider 2022 年 12 月 24 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by