Home > matGeom > geom3d > drawCircleArc3d.m

drawCircleArc3d

PURPOSE ^

Draw a 3D circle arc.

SYNOPSIS ^

function varargout = drawCircleArc3d(arc, varargin)

DESCRIPTION ^

 Draw a 3D circle arc.

   drawCircleArc3d([XC YC ZC R THETA PHI PSI START EXTENT])
   [XC YC ZC]  : coordinate of arc center
   R           : arc radius
   [THETA PHI] : orientation of arc normal, in degrees (theta: 0->180).
   PSI         : roll of arc (rotation of circle origin)
   START       : starting angle of arc, from arc origin, in degrees
   EXTENT      : extent of circle arc, in degrees (can be negative)
   
   Drawing options can be specified, as for the plot command.

   See also
     angles3d, circles3d, drawCircle3d, drawCircleArc

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = drawCircleArc3d(arc, varargin)
0002 % Draw a 3D circle arc.
0003 %
0004 %   drawCircleArc3d([XC YC ZC R THETA PHI PSI START EXTENT])
0005 %   [XC YC ZC]  : coordinate of arc center
0006 %   R           : arc radius
0007 %   [THETA PHI] : orientation of arc normal, in degrees (theta: 0->180).
0008 %   PSI         : roll of arc (rotation of circle origin)
0009 %   START       : starting angle of arc, from arc origin, in degrees
0010 %   EXTENT      : extent of circle arc, in degrees (can be negative)
0011 %
0012 %   Drawing options can be specified, as for the plot command.
0013 %
0014 %   See also
0015 %     angles3d, circles3d, drawCircle3d, drawCircleArc
0016 %
0017 
0018 % ------
0019 % Author: David Legland
0020 % e-mail: david.legland@inrae.fr
0021 % INRA - TPV URPOI - BIA IMASTE
0022 % created the 21/02/2005
0023 %
0024 
0025 %   HISTORY
0026 %   2007-06-27 change 3D angle convention
0027 %   2010-03-08 use drawPolyline3d
0028 %   2011-06-21 use angles in degrees
0029 
0030 % parse axis handle
0031 hAx = gca;
0032 if isAxisHandle(arc)
0033     hAx = arc;
0034     arc = varargin{1};
0035     varargin(1) = [];
0036 end
0037 
0038 if iscell(arc)
0039     h = [];
0040     for i = 1:length(arc)
0041         h = [h drawCircleArc3d(hAx, arc{i}, varargin{:})]; %#ok<AGROW>
0042     end
0043     if nargout > 0
0044         varargout = {h};
0045     end
0046     return;
0047 end
0048 
0049 if size(arc, 1) > 1
0050     h = [];
0051     for i = 1:size(arc, 1)
0052         h = [h drawCircleArc3d(hAx, arc(i,:), varargin{:})]; %#ok<AGROW>
0053     end
0054     if nargout > 0
0055         varargout = {h};
0056     end
0057     return;
0058 end
0059 
0060 % get center and radius
0061 xc  = arc(:,1);
0062 yc  = arc(:,2);
0063 zc  = arc(:,3);
0064 r   = arc(:,4);
0065 
0066 % get angle of normal
0067 theta   = arc(:,5);
0068 phi     = arc(:,6);
0069 psi     = arc(:,7);
0070 
0071 % get starting angle and angle extent of arc
0072 start   = arc(:,8);
0073 extent  = arc(:,9);
0074 
0075 % positions on circle arc
0076 N       = 60;
0077 t       = linspace(start, start+extent, N+1) * pi / 180;
0078 
0079 % compute coordinate of points
0080 x       = r*cos(t)';
0081 y       = r*sin(t)';
0082 z       = zeros(length(t), 1);
0083 curve   = [x y z];
0084 
0085 % compute transformation from local basis to world basis
0086 trans   = localToGlobal3d(xc, yc, zc, theta, phi, psi);
0087 
0088 % transform circle arc
0089 curve   = transformPoint3d(curve, trans);
0090 
0091 % draw the curve with specified options
0092 h = drawPolyline3d(hAx, curve, varargin{:});
0093 
0094 if nargout > 0
0095     varargout = {h};
0096 end
0097

Generated on Wed 16-Feb-2022 15:10:47 by m2html © 2003-2019