DRAWSPHERICALPOLYGON Draw a spherical polygon. output = drawSphericalPolygon(input) Example % Draw a non convex spherical polygon on the surface of a sphere sphere = [0 0 0 1]; poly = [0 -1 0;0 0 1; [-1 0 1]/sqrt(2); [-1 -1 1]/sqrt(3); [-1 -1 0]/sqrt(2)]; figure; hold on; axis equal; drawSphere([0 0 0 1]); view(3); drawSphericalPolygon(sphere, poly, 'LineWidth', 2, 'color', 'b') See also drawSphere, drawSphericalTriangle, drawSphericalEdge
0001 function varargout = drawSphericalPolygon(varargin) 0002 %DRAWSPHERICALPOLYGON Draw a spherical polygon. 0003 % 0004 % output = drawSphericalPolygon(input) 0005 % 0006 % Example 0007 % % Draw a non convex spherical polygon on the surface of a sphere 0008 % sphere = [0 0 0 1]; 0009 % poly = [0 -1 0;0 0 1; [-1 0 1]/sqrt(2); [-1 -1 1]/sqrt(3); [-1 -1 0]/sqrt(2)]; 0010 % figure; hold on; axis equal; drawSphere([0 0 0 1]); view(3); 0011 % drawSphericalPolygon(sphere, poly, 'LineWidth', 2, 'color', 'b') 0012 % 0013 % See also 0014 % drawSphere, drawSphericalTriangle, drawSphericalEdge 0015 % 0016 0017 % ------ 0018 % Author: David Legland 0019 % E-mail: david.legland@inrae.fr 0020 % Created: 2012-02-09, using Matlab 7.9.0.529 (R2009b) 0021 % Copyright 2012-2024 INRA - Cepia Software Platform 0022 0023 % extract handle of axis to draw on 0024 [hAx, varargin] = parseAxisHandle(varargin{:}); 0025 0026 sphere = varargin{1}; 0027 poly = varargin{2}; 0028 varargin(1:2) = []; 0029 0030 nv = size(poly, 1); 0031 0032 h = zeros(nv, 1); 0033 0034 % save hold state 0035 holdState = ishold(hAx); 0036 hold(hAx, 'on'); 0037 0038 for i = 1:nv 0039 v1 = poly(i, :); 0040 v2 = poly(mod(i, nv) + 1, :); 0041 0042 h(i) = drawSphericalEdge(hAx, sphere, [v1 v2], varargin{:}); 0043 end 0044 0045 % restore hold state 0046 if ~holdState 0047 hold(hAx, 'off'); 0048 end 0049 0050 if nargout > 0 0051 varargout = {h}; 0052 end