1014
|
1 # Copyright (C) 1993, 1994, 1995 John W. Eaton |
933
|
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 the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # for more details. |
|
14 # |
|
15 # You should have received a copy of the GNU General Public License |
|
16 # along with Octave; see the file COPYING. If not, write to the Free |
|
17 # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
18 |
|
19 function polar_int_2 (theta, rho, fmt) |
|
20 |
|
21 if (nargin != 3) |
|
22 usage ("polar_int_2 (theta, rho, fmt)"); |
|
23 endif |
|
24 |
|
25 if (any (imag (theta))) |
|
26 theta = real (theta); |
|
27 endif |
|
28 |
|
29 if (any (imag (rho))) |
|
30 rho = real (rho); |
|
31 endif |
|
32 |
|
33 if (is_scalar (theta)) |
|
34 if (is_scalar (rho)) |
|
35 x = rho * cos (theta); |
|
36 y = rho * sin (theta); |
|
37 plot_2_s_s (x, y, fmt); |
|
38 endif |
|
39 elseif (is_vector (theta)) |
|
40 if (is_vector (rho)) |
|
41 if (length (theta) != length (rho)) |
|
42 error ("polar: vector lengths must match"); |
|
43 endif |
|
44 if (rows (rho) == 1) |
|
45 rho = rho'; |
|
46 endif |
|
47 if (rows (theta) == 1) |
|
48 theta = theta'; |
|
49 endif |
|
50 x = rho .* cos (theta); |
|
51 y = rho .* sin (theta); |
|
52 plot_2_v_v (x, y, fmt); |
|
53 elseif (is_matrix (rho)) |
|
54 [t_nr, t_nc] = size (theta); |
|
55 if (t_nr == 1) |
|
56 theta = theta'; |
|
57 tmp = t_nr; |
|
58 t_nr = t_nc; |
|
59 t_nc = tmp; |
|
60 endif |
|
61 [r_nr, r_nc] = size (rho); |
|
62 if (t_nr != r_nr) |
|
63 rho = rho' |
|
64 tmp = r_nr; |
|
65 r_nr = r_nc; |
|
66 r_nc = tmp; |
|
67 endif |
|
68 if (t_nr != r_nr) |
|
69 error ("polar: vector and matrix sizes must match"); |
|
70 endif |
|
71 x = diag (cos (theta)) * rho; |
|
72 y = diag (sin (theta)) * rho; |
|
73 plot_2_v_m (x, y, fmt); |
|
74 endif |
|
75 elseif (is_matrix (theta)) |
|
76 if (is_vector (rho)) |
|
77 [r_nr, r_nc] = size (rho); |
|
78 if (r_nr == 1) |
|
79 rho = rho'; |
|
80 tmp = r_nr; |
|
81 r_nr = r_nc; |
|
82 r_nc = tmp; |
|
83 endif |
|
84 [t_nr, t_nc] = size (theta); |
|
85 if (r_nr != t_nr) |
|
86 theta = rho' |
|
87 tmp = t_nr; |
|
88 t_nr = t_nc; |
|
89 t_nc = tmp; |
|
90 endif |
|
91 if (r_nr != t_nr) |
|
92 error ("polar: vector and matrix sizes must match"); |
|
93 endif |
|
94 diag_r = diag (r); |
|
95 x = diag_r * cos (theta); |
|
96 y = diag_r * sin (theta); |
|
97 plot_2_m_v (x, y, fmt); |
|
98 elseif (is_matrix (rho)) |
|
99 if (size (rho) != size (theta)) |
|
100 error ("polar: matrix dimensions must match"); |
|
101 endif |
|
102 x = rho .* cos (theta); |
|
103 y = rho .* sin (theta); |
|
104 plot_2_m_m (x, y, fmt); |
|
105 endif |
|
106 endif |
|
107 |
|
108 endfunction |