0
|
1 ## Copyright (C) 1998 Ariel Tankus |
|
2 ## |
|
3 ## This program is free software. |
|
4 ## This file is part of the Image Processing Toolbox for Octave |
|
5 ## |
|
6 ## This program is free software; you can redistribute it and/or |
|
7 ## modify it under the terms of the GNU General Public License |
|
8 ## as published by the Free Software Foundation; either version 2 |
|
9 ## of the License, or (at your option) any later version. |
|
10 ## |
|
11 ## This program is distributed in the hope that it will be useful, |
|
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 ## GNU General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
|
17 ## along with this program; if not, write to the Free Software |
|
18 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
19 ## |
|
20 |
|
21 ## view Change the viewing angle for a 3-D plot. |
|
22 ## |
|
23 ## view(az, el) |
|
24 ## az - horizontal viewing angle (azimuth) [degrees]. |
|
25 ## el - vertical viewing angle (elevation) [degrees]. |
|
26 ## |
|
27 |
|
28 ## Author: Ariel Tankus <arielt@math.tau.ac.il> |
|
29 ## Created: 14.8.98. |
|
30 ## Version: 1.0 |
|
31 |
|
32 function view(az, el) |
|
33 |
|
34 ## azimuth is the same as rotation around the z-axis, |
|
35 ## so gnuplot's z_axis == az. |
|
36 az = rem(az, 360); # set az in range: [-360, 360]. |
|
37 az = az + 360*(az < 0); # set az in range: [0, 360]. |
|
38 |
|
39 ## elevation: 0 deg - equator, 90 deg - north pole. |
|
40 ## in gnuplot: 0 deg - north pole, 90 deg - equator. |
|
41 rot_x = 90 - el; |
|
42 |
|
43 ## elevation is in gnuplot coordinates |
|
44 |
|
45 rot_x = rem(rot_x, 360); # set rot_x in range: [-360, 360]. |
|
46 rot_x = rot_x + 360*(rot_x < 0); # set rot_x in range: [0, 360]. |
|
47 |
|
48 if (rot_x > 180) |
|
49 ## elevation greater than 180 degs is |
|
50 az = rem(az + 180, 360); |
|
51 rot_x = 360 - rot_x; |
|
52 end |
|
53 |
|
54 gset('view', num2str(rot_x), ',', num2str(az)); |
|
55 replot; |
|
56 |
|
57 endfunction |