Polyshape intersections in a loop

2 ビュー (過去 30 日間)
Arthur Romeu
Arthur Romeu 2021 年 4 月 26 日
Hello there,
I am currently trying to get a series of iterations for angles 000º to 360º. It basically consists of entering an initial angle and the loop stores a series of correlated coordinates in a matrix. It is rudimentary and the code is not optimised (I'm just a padawan), but I thought it would do the job, until.... angle 164º came and ruined my day. The thing is: I don't know why the code is broken! Could it have something to do with the polyshape?
Well, I turn to you, wise programmers, as my last resort in an attempt to save my poor script.
The script is attached, but in case you just want to copy and paste, it goes as follows:
clear all, clc;
Descarte_lon = -46.52904762; % Longitude do Ponto de Descarte
Descarte_lat = -26.46696384; % Latitude do Ponto de Descarte
Descarte = [Descarte_lon Descarte_lat];
buffer_1000m = polybuffer(Descarte,'lines',0.004496605);
buffer_500m = polybuffer(Descarte,'lines',0.0022483);
buffer_250m = polybuffer(Descarte,'lines',0.00112415);
buffer_100m = polybuffer(Descarte,'lines',0.0004496605);
for c = 0:360
dir_corr = c; % Direção da Corrente
corr_rad = dir_corr*pi/180;
angulo_15 = corr_rad+(15*pi/180);
angulo_15n = corr_rad+(345*pi/180);
angulo_corrente = corr_rad+pi;
angulo_corrente_j = corr_rad;
M1000_x = Descarte_lon+0.004496605*sin(angulo_15);
M1000_y = Descarte_lat+0.004496605*cos(angulo_15);
Lin_corr_x = Descarte_lon+0.004496605*sin(angulo_corrente);
Lin_corr_y = Descarte_lat+0.004496605*cos(angulo_corrente);
Lin_corr_xj = Descarte_lon+0.004496605*sin(angulo_corrente_j);
Lin_corr_yj = Descarte_lat+0.004496605*cos(angulo_corrente_j);
M1000_xn = Descarte_lon+0.004496605*sin(angulo_15n);
M1000_yn = Descarte_lat+0.004496605*cos(angulo_15n);
% hold on;
%
% plot(buffer_1000m);
% plot(buffer_500m);
% plot(buffer_250m);
% plot(buffer_100m);
%
% plot(Descarte_lon,Descarte_lat,'r.','MarkerSize',10);
%
% plot([Descarte_lon M1000_x],[Descarte_lat M1000_y],'g');
% plot([Descarte_lon M1000_xn],[Descarte_lat M1000_yn],'w');
% plot([Descarte_lon Lin_corr_x],[Descarte_lat Lin_corr_y],'k');
% plot([Descarte_lon Lin_corr_xj],[Descarte_lat Lin_corr_yj],'k')
% axis equal;
[lon1001, lat1001] = polyxpoly(buffer_1000m.Vertices(:,1),buffer_1000m.Vertices(:,2), [Descarte_lon M1000_x],[Descarte_lat M1000_y]);
%plot(lon1001, lat1001, 'bo')
[lon100, lat100] = polyxpoly(buffer_100m.Vertices(:,1),buffer_100m.Vertices(:,2), [Descarte_lon Lin_corr_xj],[Descarte_lat Lin_corr_yj]);
% plot(lon100, lat100, 'bo')
[lon250, lat250] = polyxpoly(buffer_250m.Vertices(:,1),buffer_250m.Vertices(:,2), [Descarte_lon Lin_corr_xj],[Descarte_lat Lin_corr_yj]);
% plot(lon250, lat250, 'bo')
[lon501, lat501] = polyxpoly(buffer_500m.Vertices(:,1),buffer_500m.Vertices(:,2), [Descarte_lon M1000_x],[Descarte_lat M1000_y]);
% plot(lon501, lat501, 'bo')
[lon502, lat502] = polyxpoly(buffer_500m.Vertices(:,1),buffer_500m.Vertices(:,2), [Descarte_lon Lin_corr_xj],[Descarte_lat Lin_corr_yj]);
% plot(lon502, lat502, 'bo')
[lon503, lat503] = polyxpoly(buffer_500m.Vertices(:,1),buffer_500m.Vertices(:,2), [Descarte_lon M1000_xn],[Descarte_lat M1000_yn]);
% plot(lon503, lat503, 'bo')
[lon1002, lat1002] = polyxpoly(buffer_1000m.Vertices(:,1),buffer_1000m.Vertices(:,2), [Descarte_lon Lin_corr_xj],[Descarte_lat Lin_corr_yj]);
% plot(lon1002, lat1002, 'bo')
[lon1003, lat1003] = polyxpoly(buffer_1000m.Vertices(:,1),buffer_1000m.Vertices(:,2), [Descarte_lon M1000_xn],[Descarte_lat M1000_yn]);
% plot(lon1003, lat1003, 'bo')
[lon1000, lat1000] = polyxpoly(buffer_1000m.Vertices(:,1),buffer_1000m.Vertices(:,2), [Descarte_lon Lin_corr_x],[Descarte_lat Lin_corr_y]);
% plot(lon1000, lat1000, 'bo')
DI_CORR(c+1,:) =[c, lon100, lat100, lon250, lat250, lon501, lat501, lon502, lat502, lon503, lat503, lon1001, lat1001, lon1002, lat1002, lon1003, lat1003, lon1000, lat1000];
end
Kind Regards,
Arthur.

回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by