Following the suggestion mentioned on the following thread
http://www.mathworks.com/matlabcentral/newsreader/view_thread/11300
of creating the points of a sphere and replacing those that don't fall within the desired polygon by NaNs, I was able to create a spherical patch function.
Not sure if there is any better way, but here is the piece of code FWIW.
function sphericalPatch(theta,phi,clr,alpha,r)
% alpha and phi define the [az, el] vertices of the polygonal shape
% clr is the color of the patch, alpha is the transparency and r is the sphere radius
[xb, yb, zb] = sphereMy(350,1,theta,phi,r);
surf(xb,yb,zb,'facecolor',clr,'facealpha',alpha,'edgecolor','none')
function [x, y, z] = sphereMy(varargin)
% create [x, y, z] coordinates of a sphere
% replace those x, y, z by NaNs that don't fall within the prescribed polygon
n = 20; if nargin > 0, n = varargin{1}; end
pH = 0; if nargin > 1, pH = varargin{2}; end
thetaT = 0; if nargin > 2, thetaT = varargin{3}; end
phiT= 0; if nargin > 3, phiT = varargin{4}; end
r = 1; if nargin > 4, r = varargin{5}; end
az = linspace(-pi,pi,n);
elev = linspace(-pi/2,pi/2,n);
[thetaA,phiA]=meshgrid(az,elev);
[x, y, z] = sph2cart(thetaA,phiA,r);
if pH,
inOut = inpolygon(thetaA,phiA,thetaT,phiT);
x(~inOut)=NaN;
y(~inOut)=NaN;
z(~inOut)=NaN;
end
"Yash" wrote in message <ke11v0$64o$
1...@newscl01ah.mathworks.com>...