CIRCLEARCTOPOLYLINE Convert a circle arc into a series of points. P = circleArcToPolyline(ARC, N); convert the circle ARC into a series of N points. ARC is given in the format: [XC YC R THETA1 DTHETA] where XC and YC define the center of the circle, R its radius, THETA1 is the start of the arc and DTHETA is the angle extent of the arc. Both angles are given in degrees. N is the number of vertices of the resulting polyline, default is 65. The result is a N-by-2 array containing coordinates of the N points. [X Y] = circleArcToPolyline(ARC, N); Return the result in two separate arrays with N lines and 1 column. See also: circles2d, circleToPolygon, drawCircle, drawPolygon --------- author : David Legland created the 22/05/2006. Copyright 2010 INRA - Cepia Software Platform.
0001 function varargout = circleArcToPolyline(arc, N) 0002 %CIRCLEARCTOPOLYLINE Convert a circle arc into a series of points. 0003 % 0004 % P = circleArcToPolyline(ARC, N); 0005 % convert the circle ARC into a series of N points. 0006 % ARC is given in the format: [XC YC R THETA1 DTHETA] 0007 % where XC and YC define the center of the circle, R its radius, THETA1 0008 % is the start of the arc and DTHETA is the angle extent of the arc. Both 0009 % angles are given in degrees. 0010 % N is the number of vertices of the resulting polyline, default is 65. 0011 % 0012 % The result is a N-by-2 array containing coordinates of the N points. 0013 % 0014 % [X Y] = circleArcToPolyline(ARC, N); 0015 % Return the result in two separate arrays with N lines and 1 column. 0016 % 0017 % 0018 % See also: 0019 % circles2d, circleToPolygon, drawCircle, drawPolygon 0020 % 0021 % 0022 % --------- 0023 % author : David Legland 0024 % created the 22/05/2006. 0025 % Copyright 2010 INRA - Cepia Software Platform. 0026 % 0027 0028 % HISTORY 0029 % 2011-03-30 use angles in degrees, add default value for N 0030 % 2011-12-09 rename to circleArcToPolyline 0031 0032 0033 % default value for N 0034 if nargin < 2 0035 N = 65; 0036 end 0037 0038 % vector of positions 0039 t0 = deg2rad(arc(4)); 0040 t1 = t0 + deg2rad(arc(5)); 0041 t = linspace(t0, t1, N)'; 0042 0043 % compute coordinates of vertices 0044 x = arc(1) + arc(3) * cos(t); 0045 y = arc(2) + arc(3) * sin(t); 0046 0047 % format output 0048 if nargout <= 1 0049 varargout = {[x y]}; 0050 else 0051 varargout = {x, y}; 0052 end