annotate scripts/plot/view.m @ 12377:e23ceb3fb1b6 release-3-4-x

Periodic grammarcheck of documentation.
author Rik <octave@nomad.inbox5.com>
date Sat, 05 Feb 2011 12:58:34 -0800
parents c792872f8942
children d0b799dafede
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11391
diff changeset
1 ## Copyright (C) 2007-2011 John W. Eaton
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
2 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
4 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6257
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6257
diff changeset
8 ## your option) any later version.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
9 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
14 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6257
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6257
diff changeset
17 ## <http://www.gnu.org/licenses/>.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
18
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
20 ## @deftypefn {Function File} {[@var{azimuth}, @var{elevation}] =} view ()
11567
5c18da80e28a doc fixes
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
21 ## @deftypefnx {Function File} {} view (@var{azimuth}, @var{elevation})
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
22 ## @deftypefnx {Function File} {} view ([@var{azimuth}, @var{elevation}])
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
23 ## @deftypefnx {Function File} {} view ([@var{x}, @var{y}, @var{z}])
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
24 ## @deftypefnx {Function File} {} view (@var{dims})
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
25 ## @deftypefnx {Function File} {} view (@var{ax}, @dots{})
12377
e23ceb3fb1b6 Periodic grammarcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
26 ## Query or set the viewpoint for the current axes. The parameters
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
27 ## @var{azimuth} and @var{elevation} can be given as two arguments or as
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11567
diff changeset
28 ## 2-element vector.
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11567
diff changeset
29 ## The viewpoint can also be given with Cartesian coordinates @var{x},
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11567
diff changeset
30 ## @var{y}, and @var{z}.
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
31 ## The call @code{view (2)} sets the viewpoint to @var{azimuth} = 0
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
32 ## and @var{elevation} = 90, which is the default for 2-D graphs.
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
33 ## The call @code{view (3)} sets the viewpoint to @var{azimuth} = -37.5
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
34 ## and @var{elevation} = 30, which is the default for 3-D graphs.
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
35 ## If @var{ax} is given, the viewpoint is set for this axes, otherwise
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
36 ## it is set for the current axes.
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
37 ## @end deftypefn
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
38
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
39 ## Author: jwe
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
40
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
41 function [azimuth, elevation] = view (varargin)
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
42
11345
488f07b65b1d Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents: 11344
diff changeset
43 if (nargin < 4)
7712
a626db2e8a1c view: get values from current axes if nargin == 0
John W. Eaton <jwe@octave.org>
parents: 7016
diff changeset
44 if (nargin == 0)
11391
98d523608f70 view.m: Return azimuth and elevation for nargin == 0.
Ben Abbott <bpabbott@mac.com>
parents: 11345
diff changeset
45 args = {get(gca (), "view")};
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
46 else
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
47 ax = varargin{1};
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
48 if (ishandle (ax) && strcmp (get (ax, "type"), "axes"))
11345
488f07b65b1d Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents: 11344
diff changeset
49 args = varargin(2:end);
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
50 else
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
51 ax = gca;
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
52 args = varargin;
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
53 endif
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
54 endif
11345
488f07b65b1d Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents: 11344
diff changeset
55 if (length (args) == 1)
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
56 x = args{1};
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
57 if (length (x) == 2)
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
58 az = x(1);
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
59 el = x(2);
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
60 elseif (length (x) == 3)
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
61 [az, el] = cart2sph (x(1), x(2), x(3));
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
62 az *= 180/pi;
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
63 az += 90;
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
64 el *= 180/pi;
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
65 elseif (x == 2)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
66 az = 0;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
67 el = 90;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
68 elseif (x == 3)
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
69 az = -37.5;
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 8920
diff changeset
70 el = 30;
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
71 else
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
72 print_usage ();
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
73 endif
11345
488f07b65b1d Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents: 11344
diff changeset
74 elseif (length (args) == 2)
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
75 az = args{1};
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
76 el = args{2};
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
77 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
78
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
79 if (nargin > 0)
11344
cac58372d547 Make view more compatible
Kai Habel <kai.habel@gmx.de>
parents: 10793
diff changeset
80 set (ax, "view", [az, el]);
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
81 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
82
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
83 if (nargout == 1)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
84 error ("view: T = view () not implemented");
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
85 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
86
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
87 if (nargout == 2)
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
88 azimuth = az;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
89 elevation = el;
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
90 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
91 else
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
92 print_usage ();
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
93 endif
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
94
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents:
diff changeset
95 endfunction