필터 지우기
필터 지우기

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
.

추가 답변 (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