DRAWCIRCLEARC Draw a circle arc on the current axis. drawCircleArc(ARC); Draws circle arc defined by ARC = [XC YC R START EXTENT], with (XC, YC) being the circle center, R being the circle radius, starting from angle START, and with angular extent given by EXTENT. START and EXTENT angles are given in degrees. drawCircleArc(XC, YC, R, START, EXTENT); Alternative syntax that seperates inputs. drawCircleArc(..., PARAM, VALUE); specifies plot properties by using one or several parameter name-value pairs. drawCircleArc(AX, ...); Specifies handle of the axis to draw on. H = drawCircleArc(...); Returns a handle to the created line object. Example % Draw a red thick circle arc arc = [10 20 30 -120 240]; figure; axis([-50 100 -50 100]); hold on drawCircleArc(arc, 'LineWidth', 3, 'Color', 'r') See also: circles2d, drawCircle, drawEllipse, circleArcToPolyline -------- author: David Legland INRA - TPV URPOI - BIA IMASTE created the 12/12/2003.
0001 function varargout = drawCircleArc(varargin) 0002 %DRAWCIRCLEARC Draw a circle arc on the current axis. 0003 % 0004 % drawCircleArc(ARC); 0005 % Draws circle arc defined by ARC = [XC YC R START EXTENT], with (XC, YC) 0006 % being the circle center, R being the circle radius, starting from angle 0007 % START, and with angular extent given by EXTENT. START and EXTENT angles 0008 % are given in degrees. 0009 % 0010 % drawCircleArc(XC, YC, R, START, EXTENT); 0011 % Alternative syntax that seperates inputs. 0012 % 0013 % drawCircleArc(..., PARAM, VALUE); 0014 % specifies plot properties by using one or several parameter name-value 0015 % pairs. 0016 % 0017 % drawCircleArc(AX, ...); 0018 % Specifies handle of the axis to draw on. 0019 % 0020 % H = drawCircleArc(...); 0021 % Returns a handle to the created line object. 0022 % 0023 % Example 0024 % % Draw a red thick circle arc 0025 % arc = [10 20 30 -120 240]; 0026 % figure; 0027 % axis([-50 100 -50 100]); 0028 % hold on 0029 % drawCircleArc(arc, 'LineWidth', 3, 'Color', 'r') 0030 % 0031 % See also: 0032 % circles2d, drawCircle, drawEllipse, circleArcToPolyline 0033 % 0034 % -------- 0035 % author: David Legland 0036 % INRA - TPV URPOI - BIA IMASTE 0037 % created the 12/12/2003. 0038 % 0039 0040 % HISTORY 0041 % 2004-05-03 angles are given as radians 0042 % 2007-06-27 Now uses angle extent 0043 % 2011-03-30 use angles in degrees 0044 % 2011-06-09 add support for line styles 0045 % 2011-10-11 add management of axes handle 0046 0047 if nargin == 0 0048 error('Need to specify circle arc'); 0049 end 0050 0051 0052 % extract handle of axis to draw on 0053 if isAxisHandle(varargin{1}) 0054 ax = varargin{1}; 0055 varargin(1) = []; 0056 else 0057 ax = gca; 0058 end 0059 0060 circle = varargin{1}; 0061 if size(circle, 2) == 5 0062 x0 = circle(:,1); 0063 y0 = circle(:,2); 0064 r = circle(:,3); 0065 start = circle(:,4); 0066 extent = circle(:,5); 0067 varargin(1) = []; 0068 0069 elseif length(varargin) >= 5 0070 x0 = varargin{1}; 0071 y0 = varargin{2}; 0072 r = varargin{3}; 0073 start = varargin{4}; 0074 extent = varargin{5}; 0075 varargin(1:5) = []; 0076 0077 else 0078 error('drawCircleArc: please specify center, radius and angles of circle arc'); 0079 end 0080 0081 % convert angles in radians 0082 t0 = deg2rad(start); 0083 t1 = t0 + deg2rad(extent); 0084 0085 % number of line segments 0086 N = 60; 0087 0088 % initialize handles vector 0089 h = zeros(length(x0), 1); 0090 0091 % draw each circle arc individually 0092 for i = 1:length(x0) 0093 % compute basis 0094 t = linspace(t0(i), t1(i), N+1)'; 0095 0096 % compute vertices coordinates 0097 xt = x0(i) + r(i)*cos(t); 0098 yt = y0(i) + r(i)*sin(t); 0099 0100 % draw the circle arc 0101 h(i) = plot(ax, xt, yt, varargin{:}); 0102 end 0103 0104 if nargout > 0 0105 varargout = {h}; 0106 end