Mercurial > octave-antonio
annotate scripts/general/pol2cart.m @ 20158:7503499a252b stable
doc: Update docstrings to have one sentence summary as first line.
Update scripts in audio, elfun, general, geometry, and image directories.
* scripts/audio/@audioplayer/__get_properties__.m,
scripts/audio/@audioplayer/audioplayer.m, scripts/audio/@audioplayer/get.m,
scripts/audio/@audioplayer/isplaying.m, scripts/audio/@audioplayer/play.m,
scripts/audio/@audioplayer/playblocking.m, scripts/audio/@audioplayer/set.m,
scripts/audio/@audioplayer/subsasgn.m, scripts/audio/@audioplayer/subsref.m,
scripts/audio/@audiorecorder/audiorecorder.m,
scripts/audio/@audiorecorder/get.m,
scripts/audio/@audiorecorder/getaudiodata.m,
scripts/audio/@audiorecorder/getplayer.m,
scripts/audio/@audiorecorder/isrecording.m,
scripts/audio/@audiorecorder/play.m, scripts/audio/@audiorecorder/record.m,
scripts/audio/@audiorecorder/recordblocking.m,
scripts/audio/@audiorecorder/set.m, scripts/audio/@audiorecorder/stop.m,
scripts/audio/@audiorecorder/subsasgn.m,
scripts/audio/@audiorecorder/subsref.m, scripts/audio/lin2mu.m,
scripts/audio/mu2lin.m, scripts/audio/record.m, scripts/audio/sound.m,
scripts/audio/soundsc.m, scripts/audio/wavread.m, scripts/audio/wavwrite.m,
scripts/elfun/cosd.m, scripts/elfun/sind.m, scripts/elfun/tand.m,
scripts/general/accumarray.m, scripts/general/accumdim.m,
scripts/general/bitcmp.m, scripts/general/bitget.m, scripts/general/bitset.m,
scripts/general/blkdiag.m, scripts/general/cart2pol.m,
scripts/general/cart2sph.m, scripts/general/cell2mat.m,
scripts/general/celldisp.m, scripts/general/chop.m,
scripts/general/circshift.m, scripts/general/common_size.m,
scripts/general/cplxpair.m, scripts/general/cumtrapz.m,
scripts/general/dblquad.m, scripts/general/deal.m, scripts/general/del2.m,
scripts/general/display.m, scripts/general/divergence.m,
scripts/general/fieldnames.m, scripts/general/flip.m,
scripts/general/flipdim.m, scripts/general/fliplr.m, scripts/general/flipud.m,
scripts/general/gradient.m, scripts/general/interp3.m,
scripts/general/interpft.m, scripts/general/interpn.m,
scripts/general/loadobj.m, scripts/general/logspace.m,
scripts/general/methods.m, scripts/general/nargchk.m,
scripts/general/narginchk.m, scripts/general/nargoutchk.m,
scripts/general/nextpow2.m, scripts/general/nthargout.m,
scripts/general/num2str.m, scripts/general/pol2cart.m,
scripts/general/polyarea.m, scripts/general/postpad.m,
scripts/general/prepad.m, scripts/general/profile.m, scripts/general/quadgk.m,
scripts/general/quadl.m, scripts/general/quadv.m, scripts/general/randi.m,
scripts/general/rat.m, scripts/general/repmat.m, scripts/general/rot90.m,
scripts/general/rotdim.m, scripts/general/saveobj.m, scripts/general/shift.m,
scripts/general/shiftdim.m, scripts/general/sortrows.m,
scripts/general/sph2cart.m, scripts/general/structfun.m,
scripts/general/subsindex.m, scripts/general/trapz.m,
scripts/general/triplequad.m, scripts/geometry/delaunayn.m,
scripts/geometry/dsearch.m, scripts/geometry/dsearchn.m,
scripts/geometry/griddata.m, scripts/geometry/griddata3.m,
scripts/geometry/griddatan.m, scripts/geometry/inpolygon.m,
scripts/geometry/rectint.m, scripts/geometry/tsearchn.m,
scripts/geometry/voronoi.m, scripts/geometry/voronoin.m,
scripts/help/__unimplemented__.m, scripts/help/doc.m,
scripts/help/doc_cache_create.m, scripts/help/get_first_help_sentence.m,
scripts/help/help.m, scripts/help/lookfor.m, scripts/help/print_usage.m,
scripts/help/type.m, scripts/help/which.m, scripts/image/autumn.m,
scripts/image/bone.m, scripts/image/brighten.m, scripts/image/cmpermute.m,
scripts/image/colorcube.m, scripts/image/contrast.m, scripts/image/cool.m,
scripts/image/copper.m, scripts/image/cubehelix.m, scripts/image/flag.m,
scripts/image/gmap40.m, scripts/image/gray.m, scripts/image/gray2ind.m,
scripts/image/hot.m, scripts/image/hsv.m, scripts/image/image.m,
scripts/image/imagesc.m, scripts/image/imfinfo.m, scripts/image/imformats.m,
scripts/image/imread.m, scripts/image/imshow.m, scripts/image/imwrite.m,
scripts/image/iscolormap.m, scripts/image/jet.m, scripts/image/lines.m,
scripts/image/ntsc2rgb.m, scripts/image/ocean.m, scripts/image/pink.m,
scripts/image/prism.m, scripts/image/rainbow.m, scripts/image/rgb2ntsc.m,
scripts/image/spinmap.m, scripts/image/spring.m, scripts/image/summer.m,
scripts/image/white.m, scripts/image/winter.m:
Update docstrings to have one sentence summary as first line.
Re-structure to have line lengths <= 80 chars.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 03 May 2015 09:36:20 -0700 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 2000-2015 Kai Habel |
3803 | 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. | |
3803 | 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/>. | |
3803 | 18 |
19 ## -*- texinfo -*- | |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{x}, @var{y}] =} pol2cart (@var{theta}, @var{r}) |
5610 | 21 ## @deftypefnx {Function File} {[@var{x}, @var{y}, @var{z}] =} pol2cart (@var{theta}, @var{r}, @var{z}) |
17585
36b9fa789d8e
Overhaul polar, spherical, cartesian conversion routiens when nargout == 1.
Rik <rik@octave.org>
parents:
17584
diff
changeset
|
22 ## @deftypefnx {Function File} {[@var{x}, @var{y}] =} pol2cart (@var{P}) |
36b9fa789d8e
Overhaul polar, spherical, cartesian conversion routiens when nargout == 1.
Rik <rik@octave.org>
parents:
17584
diff
changeset
|
23 ## @deftypefnx {Function File} {[@var{x}, @var{y}, @var{z}] =} pol2cart (@var{P}) |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
24 ## @deftypefnx {Function File} {@var{C} =} pol2cart (@dots{}) |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
25 ## Transform polar or cylindrical coordinates to Cartesian coordinates. |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
26 ## |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
27 ## The inputs @var{theta}, @var{r}, (and @var{z}) must be the same shape, or |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
28 ## scalar. If called with a single matrix argument then each row of @var{P} |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
29 ## represents the polar/(cylindrical) coordinate (@var{theta}, @var{r} |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
30 ## (, @var{z})). |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
31 ## |
9168
742cf6388a8f
Update section 17.7 (Coordinate Transformations) of arith.txi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
32 ## @var{theta} describes the angle relative to the positive x-axis. |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
33 ## |
8491
aaff46fef256
[docs] fix hypenation: x - axis => x-axis, etc
Brian Gough <bjg@gnu.org>
parents:
7017
diff
changeset
|
34 ## @var{r} is the distance to the z-axis (0, 0, z). |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
35 ## |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
36 ## If only a single return argument is requested then return a matrix @var{C} |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
37 ## where each row represents one Cartesian coordinate |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
38 ## (@var{x}, @var{y} (, @var{z})). |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
39 ## @seealso{cart2pol, sph2cart, cart2sph} |
3803 | 40 ## @end deftypefn |
41 | |
42 ## Author: Kai Habel <kai.habel@gmx.de> | |
43 ## Adapted-by: jwe | |
44 | |
17584
6278085742b7
pol2cart.m: Fix bug with z-input and only 1 output (bug #40184)
Rik <rik@octave.org>
parents:
16968
diff
changeset
|
45 function [x, y, z] = pol2cart (theta, r, z = []) |
3803 | 46 |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
47 if (nargin < 1 || nargin > 3) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
48 print_usage (); |
3803 | 49 endif |
50 | |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
51 if (nargin == 1) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
52 if (ismatrix (theta) && (columns (theta) == 2 || columns (theta) == 3)) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
53 if (columns (theta) == 3) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
54 z = theta(:,3); |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
55 endif |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
56 r = theta(:,2); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 theta = theta(:,1); |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
58 else |
16968
e424cdb2ef96
pol2cart.m: Correct typo in error() message.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
59 error ("pol2cart: matrix input must have 2 or 3 columns [THETA, R (, Z)]"); |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
60 endif |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
61 elseif (nargin == 2) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
62 if (! ((ismatrix (theta) && ismatrix (r)) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
63 && (size_equal (theta, r) || isscalar (theta) || isscalar (r)))) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
64 error ("pol2cart: arguments must be matrices of same size, or scalar"); |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
65 endif |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
66 elseif (nargin == 3) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
67 if (! ((ismatrix (theta) && ismatrix (r) && ismatrix (z)) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
68 && (size_equal (theta, r) || isscalar (theta) || isscalar (r)) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
69 && (size_equal (theta, z) || isscalar (theta) || isscalar (z)) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
70 && (size_equal (r, z) || isscalar (r) || isscalar (z)))) |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
71 error ("pol2cart: arguments must be matrices of same size, or scalar"); |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
72 endif |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
73 endif |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
74 |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
75 x = r .* cos (theta); |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
76 y = r .* sin (theta); |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
77 |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
78 if (nargout <= 1) |
17584
6278085742b7
pol2cart.m: Fix bug with z-input and only 1 output (bug #40184)
Rik <rik@octave.org>
parents:
16968
diff
changeset
|
79 x = [x(:), y(:), z(:)]; |
3803 | 80 endif |
81 | |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
82 endfunction |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
83 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
84 |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
85 %!test |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
86 %! t = [0, 0.5, 1] * pi; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
87 %! r = 1; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
88 %! [x, y] = pol2cart (t, r); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
89 %! assert (x, [1, 0, -1], sqrt (eps)); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
90 %! assert (y, [0, 1, 0], sqrt (eps)); |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
91 |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
92 %!test |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
93 %! t = [0, 1, 1] * pi/4; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
94 %! r = sqrt (2) * [0, 1, 2]; |
17585
36b9fa789d8e
Overhaul polar, spherical, cartesian conversion routiens when nargout == 1.
Rik <rik@octave.org>
parents:
17584
diff
changeset
|
95 %! C = pol2cart (t, r); |
36b9fa789d8e
Overhaul polar, spherical, cartesian conversion routiens when nargout == 1.
Rik <rik@octave.org>
parents:
17584
diff
changeset
|
96 %! assert (C(:,1), [0; 1; 2], sqrt (eps)); |
36b9fa789d8e
Overhaul polar, spherical, cartesian conversion routiens when nargout == 1.
Rik <rik@octave.org>
parents:
17584
diff
changeset
|
97 %! assert (C(:,2), [0; 1; 2], sqrt (eps)); |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
98 |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
99 %!test |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
100 %! t = [0, 1, 1] * pi/4; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
101 %! r = sqrt (2) * [0, 1, 2]; |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
102 %! z = [0, 1, 2]; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
103 %! [x, y, z2] = pol2cart (t, r, z); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
104 %! assert (x, [0, 1, 2], sqrt (eps)); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
105 %! assert (y, [0, 1, 2], sqrt (eps)); |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
106 %! assert (z, z2); |
3803 | 107 |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
108 %!test |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
109 %! t = 0; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
110 %! r = [0, 1, 2]; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
111 %! z = [0, 1, 2]; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
112 %! [x, y, z2] = pol2cart (t, r, z); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
113 %! assert (x, [0, 1, 2], sqrt (eps)); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
114 %! assert (y, [0, 0, 0], sqrt (eps)); |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
115 %! assert (z, z2); |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
116 |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
117 %!test |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
118 %! t = [1, 1, 1]*pi/4; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
119 %! r = 1; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
120 %! z = [0, 1, 2]; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
121 %! [x, y, z2] = pol2cart (t, r, z); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
122 %! assert (x, [1, 1, 1] / sqrt (2), eps); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
123 %! assert (y, [1, 1, 1] / sqrt (2), eps); |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
124 %! assert (z, z2); |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
125 |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
126 %!test |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
127 %! t = 0; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
128 %! r = [1, 2, 3]; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
129 %! z = 1; |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
130 %! [x, y, z2] = pol2cart (t, r, z); |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
131 %! assert (x, [1, 2, 3], eps); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
132 %! assert (y, [0, 0, 0] / sqrt (2), eps); |
8533
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
133 %! assert (z, z2); |
fb1b87ea4af9
Permit scalars when transforming coordinates.
Ben Abbott <bpabbott@mac.com>
parents:
8507
diff
changeset
|
134 |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
135 %!test |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
136 %! P = [0, 0; pi/4, sqrt(2); pi/4, 2*sqrt(2)]; |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
137 %! C = [0, 0; 1, 1; 2, 2]; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
138 %! assert (pol2cart (P), C, sqrt (eps)); |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
139 |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
140 %!test |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
141 %! P = [0, 0, 0; pi/4, sqrt(2), 1; pi/4, 2*sqrt(2), 2]; |
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
142 %! C = [0, 0, 0; 1, 1, 1; 2, 2, 2]; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
143 %! assert (pol2cart (P), C, sqrt (eps)); |
10688
7357e37f34fa
coordinate transforms: add option to operate on column matrix of coordinates.
Rik <octave@nomad.inbox5.com>
parents:
9168
diff
changeset
|
144 |