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
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 % E-mail: david.legland@inrae.fr 0025 % Created: 2006-05-22 0026 % Copyright 2006-2024 INRA - Cepia Software Platform 0027 0028 % default value for N 0029 if nargin < 2 0030 N = 65; 0031 end 0032 0033 % vector of positions 0034 t0 = deg2rad(arc(4)); 0035 t1 = t0 + deg2rad(arc(5)); 0036 t = linspace(t0, t1, N)'; 0037 0038 % compute coordinates of vertices 0039 x = arc(1) + arc(3) * cos(t); 0040 y = arc(2) + arc(3) * sin(t); 0041 0042 % format output 0043 if nargout <= 1 0044 varargout = {[x y]}; 0045 else 0046 varargout = {x, y}; 0047 end