Mercurial > hg > octave-lyh
annotate scripts/plot/view.m @ 11366:ad8966096e27
bar.m: Improve the docstring.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 14 Dec 2010 18:40:38 -0800 |
parents | 488f07b65b1d |
children | 98d523608f70 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2007, 2008 John W. Eaton |
6257 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6257 | 9 ## |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6257 | 18 |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {} view (@var{azimuth}, @var{elevation}) |
11344 | 21 ## @deftypefnx {Function File} {} view ([@var{azimuth}, @var{elevation}]) |
22 ## @deftypefnx {Function File} {} view ([@var{x}, @var{y}, @var{z}]) | |
6257 | 23 ## @deftypefnx {Function File} {} view (@var{dims}) |
11344 | 24 ## @deftypefnx {Function File} {} view (@var{ax}, @dots{}) |
6257 | 25 ## @deftypefnx {Function File} {[@var{azimuth}, @var{elevation}] =} view () |
11344 | 26 ## Set or get the viewpoint for the current axes. The parameters |
27 ## @var{azimuth} and @var{elevation} can be given as two arguments or as | |
28 ## 2-element vector. | |
29 ## The viewpoint can also be given with cartesian coordinates @var{x}, | |
30 ## @var{y}, and @var{z}. | |
31 ## The call @code{view (2)} sets the viewpoint to @var{azimuth} = 0 | |
32 ## and @var{elevation} = 90, which is default for 2d graphs. | |
33 ## The call @code{view (3)} sets the viewpoint to @var{azimuth} = -37.5 | |
34 ## and @var{elevation} = 30, which is default for 3d graphs. | |
35 ## If @var{ax} is given, the viewpoint is set for this axes, otherwise | |
36 ## it is set for the current axes. | |
6257 | 37 ## @end deftypefn |
38 | |
39 ## Author: jwe | |
40 | |
11344 | 41 function [azimuth, elevation] = view (varargin) |
6257 | 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) |
a626db2e8a1c
view: get values from current axes if nargin == 0
John W. Eaton <jwe@octave.org>
parents:
7016
diff
changeset
|
45 tmp = get (gca (), "view"); |
a626db2e8a1c
view: get values from current axes if nargin == 0
John W. Eaton <jwe@octave.org>
parents:
7016
diff
changeset
|
46 az = tmp(1); |
a626db2e8a1c
view: get values from current axes if nargin == 0
John W. Eaton <jwe@octave.org>
parents:
7016
diff
changeset
|
47 el = tmp(2); |
11344 | 48 else |
49 ax = varargin{1}; | |
50 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
|
51 args = varargin(2:end); |
11344 | 52 else |
53 ax = gca; | |
54 args = varargin; | |
55 endif | |
56 endif | |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
57 if (length (args) == 1) |
11344 | 58 x = args{1}; |
59 if (length (x) == 2) | |
60 az = x(1); | |
61 el = x(2); | |
62 elseif (length (x) == 3) | |
63 [az, el] = cart2sph (x(1), x(2), x(3)); | |
64 az *= 180/pi; | |
65 az += 90; | |
66 el *= 180/pi; | |
67 elseif (x == 2) | |
10549 | 68 az = 0; |
69 el = 90; | |
6257 | 70 elseif (x == 3) |
10549 | 71 az = -37.5; |
72 el = 30; | |
6257 | 73 else |
11344 | 74 print_usage (); |
6257 | 75 endif |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
76 elseif (length (args) == 2) |
11344 | 77 az = args{1}; |
78 el = args{2}; | |
6257 | 79 endif |
80 | |
81 if (nargin > 0) | |
11344 | 82 set (ax, "view", [az, el]); |
6257 | 83 endif |
84 | |
85 if (nargout == 1) | |
86 error ("view: T = view () not implemented"); | |
87 endif | |
88 | |
89 if (nargout == 2) | |
90 azimuth = az; | |
91 elevation = el; | |
92 endif | |
93 else | |
94 print_usage (); | |
95 endif | |
96 | |
97 endfunction |