DRAWSPHERICALEDGE Draw an edge on the surface of a sphere. drawSphericalEdge(SPHERE, EDGE) EDGE is given as a couple of 3D coordinates corresponding to edge extremities. The shortest spherical edge joining the two extremities is drawn on the current axes. Example drawSphericalEdge See also drawSphericalPolygon ------ Author: David Legland e-mail: david.legland@grignon.inra.fr Created: 2012-02-09, using Matlab 7.9.0.529 (R2009b) Copyright 2012 INRA - Cepia Software Platform.
0001 function varargout = drawSphericalEdge(sphere, edge, varargin) 0002 %DRAWSPHERICALEDGE Draw an edge on the surface of a sphere. 0003 % 0004 % drawSphericalEdge(SPHERE, EDGE) 0005 % EDGE is given as a couple of 3D coordinates corresponding to edge 0006 % extremities. The shortest spherical edge joining the two extremities is 0007 % drawn on the current axes. 0008 % 0009 % Example 0010 % drawSphericalEdge 0011 % 0012 % See also 0013 % drawSphericalPolygon 0014 % 0015 % ------ 0016 % Author: David Legland 0017 % e-mail: david.legland@grignon.inra.fr 0018 % Created: 2012-02-09, using Matlab 7.9.0.529 (R2009b) 0019 % Copyright 2012 INRA - Cepia Software Platform. 0020 0021 0022 % extract data of the sphere 0023 origin = sphere(:, 1:3); 0024 0025 % extremities of current edge 0026 point1 = edge(1:3); 0027 point2 = edge(4:6); 0028 0029 % compute plane containing current edge 0030 plane = createPlane(origin, point1, point2); 0031 0032 % intersection of the plane with unit sphere 0033 circle = intersectPlaneSphere(plane, sphere); 0034 0035 % find the position (in degrees) of the 2 vertices on the circle 0036 angle1 = circle3dPosition(point1, circle); 0037 angle2 = circle3dPosition(point2, circle); 0038 0039 % ensure angles are in right direction 0040 if mod(angle2 - angle1 + 360, 360) > 180 0041 tmp = angle1; 0042 angle1 = angle2; 0043 angle2 = tmp; 0044 end 0045 0046 % compute angle extent of the circle arc 0047 angleExtent = mod(angle2 - angle1 + 360, 360); 0048 0049 % create circle arc 0050 arc = [circle angle1 angleExtent]; 0051 0052 % draw the arc 0053 h = drawCircleArc3d(arc, varargin{:}); 0054 0055 if nargout > 0 0056 varargout = {h}; 0057 end