1## Copyright (C) 2007, 2009 Michael Goffioul and Kai Habel
3## This file is part of Octave.
5## Octave is free software; you can redistribute it and/or modify it
6## under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 3 of the License, or (at
8## your option) any later version.
10## Octave is distributed in the hope that it will be useful, but
11## WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13## General Public License for more details.
15## You should have received a copy of the GNU General Public License
16## along with Octave; see the file COPYING. If not, see
17## <http://www.gnu.org/licenses/>.
20## @deftypefn {Function File} {} cylinder
21## @deftypefnx {Function File} {} cylinder (@var{r})
22## @deftypefnx {Function File} {} cylinder (@var{r}, @var{n})
23## @deftypefnx {Function File} {[@var{x}, @var{y}, @var{z}] =} cylinder (@dots{})
24## @deftypefnx {Function File} {} cylinder (@var{ax}, @dots{})
25## Generates three matrices in @code{meshgrid} format, such that
26## @code{surf (@var{x}, @var{y}, @var{z})} generates a unit cylinder.
27## The matrices are of size @code{@var{n}+1}-by-@code{@var{n}+1}.
28## @var{r} is a vector containing the radius along the z-axis.
29## If @var{n} or @var{r} are omitted then default values of 20 or [1 1]
32## Called with no return arguments, @code{cylinder} calls directly
33## @code{surf (@var{x}, @var{y}, @var{z})}. If an axes handle @var{ax}
34## is passed as the first argument, the surface is plotted to this set
40## disp ("plotting a cone")
41## [x, y, z] = cylinder (10:-1:0,50);
48function [xx, yy, zz] = cylinder (varargin)
50 [ax, args, nargs] = __plt_get_axis_arg__ ((nargout > 0), "cylinder",
67 error ("cylinder: length(r) must be larger than 2")
70 phi = linspace (0, 2*pi, n+1);
72 [phi, idx] = meshgrid(phi, idx);
73 z = (idx - 1) / (length(r) - 1);
75 [x, y] = pol2cart (phi, r);
88%! disp ("plotting a cone")
89%! [x, y, z] = cylinder (10:-1:0,50);