1 %% Copyright (c) 2011, INRA
2 %% 2003-2011, David Legland <david.legland@grignon.inra.fr>
3 %% 2011 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
5 %% All rights reserved.
6 %% (simplified BSD License)
8 %% Redistribution and use in source and binary forms, with or without
9 %% modification, are permitted provided that the following conditions are met:
11 %% 1. Redistributions of source code must retain the above copyright notice, this
12 %% list of conditions and the following disclaimer.
14 %% 2. Redistributions in binary form must reproduce the above copyright notice,
15 %% this list of conditions and the following disclaimer in the documentation
16 %% and/or other materials provided with the distribution.
18 %% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 %% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 %% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 %% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 %% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 %% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 %% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 %% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 %% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 %% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 %% POSSIBILITY OF SUCH DAMAGE.
30 %% The views and conclusions contained in the software and documentation are
31 %% those of the authors and should not be interpreted as representing official
32 %% policies, either expressed or implied, of copyright holder.
35 %% @deftypefn {Function File} {@var{h} = } drawCircleArc (@var{xc}, @var{yc}, @var{r}, @var{start}, @var{end})
36 %% @deftypefnx {Function File} {@var{h} = } drawCircleArc (@var{arc})
37 %% @deftypefnx {Function File} {@var{h} = } drawCircleArc (@dots{}, @var{param}, @var{value})
38 %% Draw a circle arc on the current axis
40 %% drawCircleArc(XC, YC, R, START, EXTENT);
41 %% Draws circle with center (XC, YC), with radius R, starting from angle
42 %% START, and with angular extent given by EXTENT. START and EXTENT angles
43 %% are given in degrees.
45 %% drawCircleArc(ARC);
46 %% Puts all parameters into one single array.
48 %% drawCircleArc(..., PARAM, VALUE);
49 %% specifies plot properties by using one or several parameter name-value
52 %% H = drawCircleArc(...);
53 %% Returns a handle to the created line object.
56 %% % Draw a red thick circle arc
57 %% arc = [10 20 30 -120 240];
59 %% axis([-50 100 -50 100]);
61 %% drawCircleArc(arc, 'LineWidth', 3, 'Color', 'r')
64 %% @seealso{circles2d, drawCircle, drawEllipse}
67 function varargout = drawCircleArc(varargin)
70 error('Need to specify circle arc');
74 if size(circle, 2) == 5
82 elseif length(varargin) >= 5
91 error('drawCircleArc: please specify center, radius and angles of circle arc');
94 % convert angles in radians
96 t1 = t0 + deg2rad(extent);
98 % number of line segments
101 % initialize handles vector
102 h = zeros(length(x0), 1);
104 % draw each circle arc individually
107 t = linspace(t0(i), t1(i), N+1)';
109 % compute vertices coordinates
110 xt = x0(i) + r(i)*cos(t);
111 yt = y0(i) + r(i)*sin(t);
113 % draw the circle arc
114 h(i) = plot(xt, yt, varargin{:});