Function fillm paints all map when the north pole is inside polygon.

When I try to paint a rectangle whose vertices are positioned around the north pole then the fillm function paints the whole map instead of the rectangle. In some cases it works but in some it deosn't. Here's my code:
figure('units', 'normalized', 'outerposition', [0 0 1 1], 'Color',[1 1 1], 'Renderer','opengl', 'Visible', 'on');
axesm( 'eqdazim' , 'Grid', 'on' , 'Origin' , [90 0 0] , ...
'MLineLocation', 15 , 'PLineLocation', 15 , ...
'MeridianLabel', 'off' , 'ParallelLabel', 'off' , ...
'FLatLimit' , [-90 90] , 'FLonLimit' , [-180 180] , ...
'MapLatLimit' , [80 90] , 'MapLonLimit' , [-180 180] );
% Coordinates that work
lats_good = [87.73,89.49,89.80,87.78,87.73];
lons_good = [47.63,-48.74,-156.74,62.95,47.63];
% Coordinates that do not work
lats_bad = [87.77,87.75,89.57,89.73,87.77];
lons_bad = [29.82,45.23,147.81,-93.04,29.82];
fillm(lats_good, lons_good, 'FaceColor', 'r', 'FaceAlpha', 0.5, 'EdgeColor', 'k', 'EdgeAlpha', 0.8);
hold on
fillm(lats_bad, lons_bad, 'FaceColor', 'b', 'FaceAlpha', 0.5, 'EdgeColor', 'k', 'EdgeAlpha', 0.8);
If I use coordinates marked as 'good' I can plot a rectangle properly. But not if I use the ones marked as 'bad'. I can't find the issue.

Answers (0)

Products

Release

R2021a

Asked:

on 19 Apr 2023

Community Treasure Hunt

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

Start Hunting!