annotate scripts/plot/util/rotate.m @ 21581:6fab85c1538f

maint: Follow Octave conventions for use of semicolon in BIST tests. * testfun.txi: Document Octave conventions for use of semicolon in BIST tests. * cellfun.cc, ellipj.cc, file-io.cc, gcd.cc, hash.cc, nproc.cc, utils.cc, fftw.cc, ov-usr-fcn.cc, oct-parse.in.yy, md5sum.m, wavread.m, wavwrite.m, cplxpair.m, rat.m, im2double.m, rref.m, stem3.m, rotate.m, pchip.m, blackman.m, hamming.m, hanning.m, spectral_adf.m, spectral_xdf.m, assert.m, fail.m, etime.m, build-sparse-tests.sh, classes.tst, ctor-vs-method.tst, index.tst, io.tst, struct.tst: Follow Octave conventions for use of semicolon in BIST tests.
author Rik <rik@octave.org>
date Fri, 01 Apr 2016 18:16:01 -0700
parents 516bb87ea72e
children b002b4331a12
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19272
diff changeset
1 ## Copyright (C) 2014-2015 John W. Eaton
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 ##
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 ## This file is part of Octave.
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 ##
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 ## your option) any later version.
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 ##
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ## General Public License for more details.
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 ##
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20231
diff changeset
20 ## @deftypefn {} {} rotate (@var{h}, @var{dir}, @var{alpha})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20231
diff changeset
21 ## @deftypefnx {} {} rotate (@dots{}, @var{origin})
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
22 ## Rotate the plot object @var{h} through @var{alpha} degrees around the line
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
23 ## with direction @var{dir} and origin @var{origin}.
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
25 ## The default value of @var{origin} is the center of the axes object that is
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
26 ## the parent of @var{h}.
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
28 ## If @var{h} is a vector of handles, they must all have the same parent axes
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
29 ## object.
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
31 ## Graphics objects that may be rotated are lines, surfaces, patches, and
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
32 ## images.
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 ## @end deftypefn
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 function rotate (h, direction, alpha, origin)
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 ## Note in doc string about compatibility issues with calculation of
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 ## default origin due to possible differences in the auto-scaling
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 ## algorithm between Octave and Matlab.
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 if (nargin < 3 || nargin > 4)
19272
26d1c3b73174 * rotate.m: Fix typo.
John W. Eaton <jwe@octave.org>
parents: 19152
diff changeset
42 print_usage ();
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 is_h = ishandle (h);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 if (is_h)
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 ax_list = get (h, "parent");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 if (iscell (ax_list))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 ax_list = cell2mat (ax_list);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 if (ax_list == ax_list(1))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 ax = ax_list(1);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 else
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 error ("rotate: all handles must be children of the same axes object");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 else
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 error ("rotate: H must be an array of one or more graphics handles");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 if (! (isnumeric (direction) && numel (direction) == 3))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 error ("rotate: invalid direction");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 if (! (isnumeric (alpha) && isscalar (alpha)))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 error ("rotate: invalid rotation angle");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 t = get (h, "type");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 is_image = strcmp (t, "image");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 is_line = strcmp (t, "line");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 is_patch = strcmp (t, "patch");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 is_surface = strcmp (t, "surface");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 if (! all (is_image | is_line | is_patch | is_surface))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 error ("rotate: expecting image, line, patch, or surface objects");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 if (nargin == 4)
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 if (! (isnumeric (origin) && numel (origin) == 3))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 error ("rotate: invalid origin");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 else
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 ## Should Z limit be considered when computing origin?
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 use_zlim = any (is_patch | is_surface);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 if (! use_zlim && any (is_line))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 idx = find (is_line)';
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 for i = idx
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 if (! isempty (get (h(i), "zdata")))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 use_zlim = true;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 break;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 endfor
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 xlim = get (ax, "xlim");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 ylim = get (ax, "ylim");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 a = (xlim(1) + xlim(2)) / 2;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 b = (ylim(1) + ylim(2)) / 2;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 if (use_zlim)
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 zlim = get (ax, "zlim");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 c = (zlim(1) + zlim(2)) / 2;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 else
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 c = 0;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 origin = [a, b, c];
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 20173
diff changeset
114 direction /= norm (direction);
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 u = direction(1);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117 v = direction(2);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 w = direction(3);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 a = origin(1);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 b = origin(2);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 c = origin(3);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124 sa = sind (alpha);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 ca = cosd (alpha);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 for i = 1:numel (h)
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 x = get (h(i), "xdata");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 y = get (h(i), "ydata");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 if (is_image(i))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 z = zeros (size (x));
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 else
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 z = get (h(i), "zdata");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 if (isempty (z))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 z = zeros (size (x));
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137 elseif (isvector (x) && isvector (y) && ! isvector (z))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 [x, y] = meshgrid (x, y);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 if (a == 0 && b == 0 && c == 0)
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143 tmp = (u*x + v*y + w*z) * (1 - ca);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145 xr = u*tmp + x*ca + (-w*y + v*z)*sa;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 yr = v*tmp + y*ca + (w*x - u*z)*sa;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 zr = w*tmp + z*ca + (-v*x + u*y)*sa;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 else
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149 one_m_ca = 1 - ca;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 tmp = u*x + v*y + w*z;
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152 xr = ((a*(v**2 + w**2) - u*(b*v + c*w - tmp))*one_m_ca
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 + x*ca + (-c*v + b*w - w*y + v*z)*sa);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154 yr = ((b*(u**2 + w**2) - v*(a*u + c*w - tmp))*one_m_ca
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 + y*ca + (c*u - a*w + w*x - u*z)*sa);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 zr = ((c*(u**2 + v**2) - w*(a*u + b*v - tmp))*one_m_ca
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 + z*ca + (-b*u + a*v - v*x + u*y)*sa);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 set (h(i), "xdata", xr, "ydata", yr);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 if (! is_image(i))
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 set (h(i), "zdata", zr);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 endif
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165 endfor
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 endfunction
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
169 ## Test input validation
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170 %!shared h1, h2, o1, o2, o3
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171 %! h1 = figure ("visible", "off");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 %! o1 = line ();
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 %! h2 = figure ("visible", "off");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 %! o2 = line ();
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 %! o3 = text (0, 0, "foobar");
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176 %!error rotate ()
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 %!error rotate (o1)
21581
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
178 %!error rotate (o1, [0,0,0])
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
179 %!error <all handles must be children of the same axes object> rotate ([o1, o2], [0,0,0], 90)
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
180 %!error <invalid direction> rotate (o1, "foo", 90)
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
181 %!error <invalid rotation angle> rotate (o1, [0,0,0], "foo")
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
182 %!error <invalid origin> rotate (o1, [0,0,0], 90, "foo")
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
183 %!error rotate (o1, [0,0,0], 90, [0,0,0], 1)
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
184 %!error <H must be an array of one or more graphics handles> rotate (NaN, [0,0,0], 90)
6fab85c1538f maint: Follow Octave conventions for use of semicolon in BIST tests.
Rik <rik@octave.org>
parents: 20852
diff changeset
185 %!error <expecting image, line, patch, or surface objects> rotate (o3, [0,0,0], 90)
19081
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186 %!test
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 %! close (h1);
d59d052c9858 rotate.m: new function
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 %! close (h2);