annotate scripts/plot/draw/ostreamtube.m @ 31706:597f3ee61a48 stable

update Octave Project Developers copyright for the new year
author John W. Eaton <jwe@octave.org>
date Fri, 06 Jan 2023 13:11:27 -0500
parents 796f54d4ddbf
children 2e484f9f1f18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
31706
597f3ee61a48 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30564
diff changeset
3 ## Copyright (C) 2019-2023 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27810
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
7 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
8 ## This file is part of Octave.
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
9 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
13 ## (at your option) any later version.
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
14 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
18 ## GNU General Public License for more details.
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
19 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
25
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
26 ## -*- texinfo -*-
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
27 ## @deftypefn {} {} ostreamtube (@var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w}, @var{sx}, @var{sy}, @var{sz})
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
28 ## @deftypefnx {} {} ostreamtube (@var{u}, @var{v}, @var{w}, @var{sx}, @var{sy}, @var{sz})
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
29 ## @deftypefnx {} {} ostreamtube (@var{xyz}, @var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w})
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
30 ## @deftypefnx {} {} ostreamtube (@dots{}, @var{options})
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
31 ## @deftypefnx {} {} ostreamtube (@var{hax}, @dots{})
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
32 ## @deftypefnx {} {@var{h} =} ostreamtube (@dots{})
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
33 ## Calculate and display streamtubes.
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
34 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
35 ## Streamtubes are approximated by connecting circular crossflow areas
27794
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
36 ## along a streamline. The expansion of the flow is determined by the local
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
37 ## crossflow divergence.
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
38 ##
27794
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
39 ## The vector field is given by @code{[@var{u}, @var{v}, @var{w}]} and is
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
40 ## defined over a rectangular grid given by @code{[@var{x}, @var{y}, @var{z}]}.
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
41 ## The streamtubes start at the seed points
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
42 ## @code{[@var{sx}, @var{sy}, @var{sz}]}.
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
43 ##
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
44 ## The tubes are colored based on the local vector field strength.
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
45 ##
27794
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
46 ## The input parameter @var{options} is a 2-D vector of the form
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
47 ## @code{[@var{scale}, @var{n}]}. The first parameter scales the start radius
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
48 ## of the streamtubes (default 1). The second parameter specifies the number
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
49 ## of vertices that are used to construct the tube circumference (default 20).
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
50 ##
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
51 ## @code{ostreamtube} can be called with a cell array containing pre-computed
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
52 ## streamline data. To do this, @var{xyz} must be created with the
27794
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
53 ## @code{stream3} function. This option is useful if you need to alter the
45ad2127582b doc: grammarcheck scripts before 6.1 release.
Rik <rik@octave.org>
parents: 27759
diff changeset
54 ## integrator step size or the maximum number of vertices of the streamline.
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
55 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
56 ## If the first argument @var{hax} is an axes handle, then plot into this axes,
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
57 ## rather than the current axes returned by @code{gca}.
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
58 ##
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
59 ## The optional return value @var{h} is a graphics handle to the plot
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
60 ## objects created for each streamtube.
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
61 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
62 ## Example:
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
63 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
64 ## @example
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
65 ## @group
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
66 ## [x, y, z] = meshgrid (-1:0.1:1, -1:0.1:1, -3:0.1:0);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
67 ## u = -x / 10 - y;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
68 ## v = x - y / 10;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
69 ## w = - ones (size (x)) / 10;
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
70 ## ostreamtube (x, y, z, u, v, w, 1, 0, 0);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
71 ## @end group
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
72 ## @end example
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
73 ##
28386
8a9a041db1dc Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28385
diff changeset
74 ## @seealso{stream3, streamline, streamribbon, streamtube}
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
75 ## @end deftypefn
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
76
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
77 ## References:
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
78 ##
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
79 ## @inproceedings{
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
80 ## title = {Visualization of 3-D vector fields - Variations on a stream},
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
81 ## author = {Dave Darmofal and Robert Haimes},
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
82 ## year = {1992}
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
83 ## }
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
84 ##
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
85 ## @article{
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
86 ## title = {Efficient streamline, streamribbon, and streamtube constructions on unstructured grids},
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
87 ## author = {Ueng, Shyh-Kuang and Sikorski, C. and Ma, Kwan-Liu},
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
88 ## year = {1996},
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
89 ## month = {June},
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
90 ## publisher = {IEEE Transactions on Visualization and Computer Graphics},
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
91 ## }
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
92
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
93 function h = ostreamtube (varargin)
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
94
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
95 [hax, varargin, nargin] = __plt_get_axis_arg__ ("ostreamtube", varargin{:});
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
96
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
97 options = [];
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
98 xyz = [];
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
99 switch (nargin)
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
100 case 6
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
101 [u, v, w, spx, spy, spz] = varargin{:};
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
102 [m, n, p] = size (u);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
103 [x, y, z] = meshgrid (1:n, 1:m, 1:p);
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
104 case 7
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
105 if (iscell (varargin{1}))
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
106 [xyz, x, y, z, u, v, w] = varargin{:};
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
107 else
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
108 [u, v, w, spx, spy, spz, options] = varargin{:};
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
109 [m, n, p] = size (u);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
110 [x, y, z] = meshgrid (1:n, 1:m, 1:p);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
111 endif
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
112 case 8
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
113 [xyz, x, y, z, u, v, w, options] = varargin{:};
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
114 case 9
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
115 [x, y, z, u, v, w, spx, spy, spz] = varargin{:};
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
116 case 10
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
117 [x, y, z, u, v, w, spx, spy, spz, options] = varargin{:};
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
118 otherwise
28901
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
119 print_usage ();
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
120 endswitch
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
121
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
122 scale = 1;
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
123 num_circum = 20;
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
124 if (! isempty (options))
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
125 switch (numel (options))
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
126 case 1
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
127 scale = options(1);
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
128 case 2
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
129 scale = options(1);
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
130 num_circum = options(2);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
131 otherwise
28901
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
132 error ("ostreamtube: OPTIONS must be a 1- or 2-element vector");
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
133 endswitch
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
134
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
135 if (! isreal (scale) || scale <= 0)
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
136 error ("ostreamtube: SCALE must be a real scalar > 0");
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
137 endif
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
138 if (! isreal (num_circum) || num_circum < 3)
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
139 error ("ostreamtube: number of tube vertices N must be greater than 2");
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
140 endif
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
141 num_circum = fix (num_circum);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
142 endif
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
143
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
144 if (isempty (hax))
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
145 hax = gca ();
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
146 else
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
147 hax = hax(1);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
148 endif
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
149
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
150 if (isempty (xyz))
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
151 xyz = stream3 (x, y, z, u, v, w, spx, spy, spz, 0.2);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
152 endif
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
153
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
154 div = divergence (x, y, z, u, v, w);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
155
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
156 ## Use the bounding box diagonal to determine the starting radius
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
157 mxx = mnx = mxy = mny = mxz = mnz = [];
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
158 j = 1;
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
159 for i = 1 : length (xyz)
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
160 sl = xyz{i};
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
161 if (! isempty (sl))
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
162 slx = sl(:,1); sly = sl(:,2); slz = sl(:,3);
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
163 mxx(j) = max (slx); mnx(j) = min (slx);
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
164 mxy(j) = max (sly); mny(j) = min (sly);
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
165 mxz(j) = max (slz); mnz(j) = min (slz);
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
166 j += 1;
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
167 endif
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
168 endfor
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
169 dx = max (mxx) - min (mnx);
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
170 dy = max (mxy) - min (mny);
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
171 dz = max (mxz) - min (mnz);
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
172 rstart = scale * sqrt (dx*dx + dy*dy + dz*dz) / 25;
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
173
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
174 h = [];
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
175 for i = 1 : length (xyz)
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
176 sl = xyz{i};
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
177 num_vertices = rows (sl);
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
178 if (! isempty (sl) && num_vertices > 2)
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
179
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
180 usl = interp3 (x, y, z, u, sl(:,1), sl(:,2), sl(:,3));
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
181 vsl = interp3 (x, y, z, v, sl(:,1), sl(:,2), sl(:,3));
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
182 wsl = interp3 (x, y, z, w, sl(:,1), sl(:,2), sl(:,3));
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
183 vv = sqrt (usl.*usl + vsl.*vsl + wsl.*wsl);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
184
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
185 div_sl = interp3 (x, y, z, div, sl(:,1), sl(:,2), sl(:,3));
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
186 is_singular_div = find (isnan (div_sl), 1, "first");
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
187
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
188 if (! isempty (is_singular_div))
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
189 max_vertices = is_singular_div - 1;
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
190 else
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
191 max_vertices = num_vertices;
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
192 endif
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
193
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
194 if (max_vertices > 2)
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
195
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
196 htmp = plottube (hax, sl, div_sl, vv, max_vertices, ...
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
197 rstart, num_circum);
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
198 h = [h; htmp];
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
199
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
200 endif
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
201 endif
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
202 endfor
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
203
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
204 endfunction
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
205
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
206 function h = plottube (hax, sl, div_sl, vv, max_vertices, rstart, num_circum)
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
207
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
208 phi = linspace (0, 2*pi, num_circum);
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
209 cp = cos (phi);
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
210 sp = sin (phi);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
211
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
212 ## 1st streamline segment
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
213 X0 = sl(1,:);
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
214 X1 = sl(2,:);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
215 R = X1 - X0;
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
216 RE = R / norm (R);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
217
28384
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
218 ## Guide point and its rotation to create a segment
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
219 KE = get_normal1 (RE);
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
220 K = rstart * KE;
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
221 XS0 = rotation (K, RE, cp, sp) + repmat (X0.', 1, num_circum);
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
222
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
223 ## End of first segment
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
224 ract = rstart * exp (0.5 * div_sl(2) * norm (R) / vv(2)) * ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
225 sqrt (vv(1) / vv(2));
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
226 rold = ract;
28384
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
227 K = ract * KE;
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
228 XS = rotation (K, RE, cp, sp) + repmat (X1.', 1, num_circum);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
229
28384
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
230 px = zeros (num_circum, max_vertices);
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
231 py = zeros (num_circum, max_vertices);
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
232 pz = zeros (num_circum, max_vertices);
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
233 pc = zeros (num_circum, max_vertices);
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
234
28384
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
235 px(:,1) = XS0(1,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
236 py(:,1) = XS0(2,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
237 pz(:,1) = XS0(3,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
238 pc(:,1) = vv(1) * ones (num_circum, 1);
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
239
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
240 px(:,2) = XS(1,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
241 py(:,2) = XS(2,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
242 pz(:,2) = XS(3,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
243 pc(:,2) = vv(2) * ones (num_circum, 1);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
244
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
245 for i = 3 : max_vertices
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
246
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
247 ## Next streamline segment
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
248 X0 = X1;
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
249 X1 = sl(i,:);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
250 R = X1 - X0;
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
251 RE = R / norm (R);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
252
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
253 ## Tube radius
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
254 ract = rold * exp (0.5 * div_sl(i) * norm (R) / vv(i)) * ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
255 sqrt (vv(i-1) / vv(i));
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
256 rold = ract;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
257
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
258 ## Project KE onto RE and get the difference in order to transport
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
259 ## the normal vector KE along the vertex array
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
260 Kp = KE - RE * dot (KE, RE);
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
261 KE = Kp / norm (Kp);
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
262 K = ract * KE;
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
263
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
264 ## Rotate around RE and collect surface patches
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
265 XS = rotation (K, RE, cp, sp) + repmat (X1.', 1, num_circum);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
266
28384
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
267 px(:,i) = XS(1,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
268 py(:,i) = XS(2,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
269 pz(:,i) = XS(3,:).';
23e6c897526a ostreamtube.m: Plot 1st tube segment (bug #58096).
Markus Meisinger <chloros2@gmx.de>
parents: 28136
diff changeset
270 pc(:,i) = vv(i) * ones (num_circum, 1);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
271
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
272 endfor
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
273
28036
465be7c652f1 streamtube: Change used graphics object and tube radius (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28035
diff changeset
274 h = surface (hax, px, py, pz, pc);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
275
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
276 endfunction
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
277
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
278 ## Arbitrary N normal to X
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
279 function N = get_normal1 (X)
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
280
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
281 if ((X(3) == 0) && (X(1) == -X(2)))
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
282 N = [(- X(2) - X(3)), X(1), X(1)];
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
283 else
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
284 N = [X(3), X(3), (- X(1) - X(2))];
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
285 endif
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
286
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
287 N /= norm (N);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
288
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
289 endfunction
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
290
28035
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
291 ## Rotate X around U where |U| = 1
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
292 ## cp = cos (angle), sp = sin (angle)
0cd5f632a4b0 streamtube.m: Clean up function (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 27984
diff changeset
293 function Y = rotation (X, U, cp, sp)
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
294
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
295 ux = U(1);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
296 uy = U(2);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
297 uz = U(3);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
298
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
299 Y(1,:) = X(1) * (cp + ux * ux * (1 - cp)) + ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
300 X(2) * (ux * uy * (1 - cp) - uz * sp) + ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
301 X(3) * (ux * uz * (1 - cp) + uy * sp);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
302
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
303 Y(2,:) = X(1) * (uy * ux * (1 - cp) + uz * sp) + ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
304 X(2) * (cp + uy * uy * (1 - cp)) + ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
305 X(3) * (uy * uz * (1 - cp) - ux * sp);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
306
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
307 Y(3,:) = X(1) * (uz * ux * (1 - cp) - uy * sp) + ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
308 X(2) * (uz * uy * (1 - cp) + ux * sp) + ...
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
309 X(3) * (cp + uz * uz * (1 - cp));
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
310
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
311 endfunction
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
312
28931
c5b1bbb95a66 maint: start %!demo or %!test blocks 2 newlines after endfunction.
Rik <rik@octave.org>
parents: 28901
diff changeset
313
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
314 %!demo
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
315 %! clf;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
316 %! [x, y, z] = meshgrid (-1:0.1:1, -1:0.1:1, -3.5:0.1:0);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
317 %! a = 0.1;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
318 %! b = 0.1;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
319 %! u = - a * x - y;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
320 %! v = x - a * y;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
321 %! w = - b * ones (size (x));
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
322 %! sx = 1.0;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
323 %! sy = 0.0;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
324 %! sz = 0.0;
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
325 %! ostreamtube (x, y, z, u, v, w, sx, sy, sz, [1.2, 30]);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
326 %! colormap (jet);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
327 %! shading interp;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
328 %! view ([-47, 24]);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
329 %! camlight ();
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
330 %! lighting gouraud;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
331 %! grid on;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
332 %! view (3);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
333 %! axis equal;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
334 %! set (gca, "cameraviewanglemode", "manual");
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
335 %! title ("Spiral Sink");
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
336
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
337 %!demo
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
338 %! clf;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
339 %! [x, y, z] = meshgrid (-2:0.5:2);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
340 %! t = sqrt (1.0./(x.^2 + y.^2 + z.^2)).^3;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
341 %! u = - x.*t;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
342 %! v = - y.*t;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
343 %! w = - z.*t;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
344 %! [sx, sy, sz] = meshgrid (-2:4:2);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
345 %! xyz = stream3 (x, y, z, u, v, w, sx, sy, sz, [0.1, 60]);
28135
695bb31e565b Rename "streamtube" to "ostreamtube" (bug #57471).
Markus Meisinger <chloros2@gmx.de>
parents: 28036
diff changeset
346 %! ostreamtube (xyz, x, y, z, u, v, w, [2, 50]);
27759
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
347 %! colormap (jet);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
348 %! shading interp;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
349 %! view ([-47, 24]);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
350 %! camlight ();
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
351 %! lighting gouraud;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
352 %! grid on;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
353 %! view (3);
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
354 %! axis equal;
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
355 %! set (gca, "cameraviewanglemode", "manual");
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
356 %! title ("Integration Towards Sink");
992e702ef0d7 Add stream* functions (patch #9859).
Markus Meisinger <chloros2@gmx.de>
parents:
diff changeset
357
27810
f2b89a2e20b6 overhaul streamXXX.m series of functions.
Rik <rik@octave.org>
parents: 27794
diff changeset
358 ## Test input validation
28896
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 28386
diff changeset
359 %!error <Invalid call> ostreamtube ()
28901
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
360 %!error <Invalid call> ostreamtube (1)
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
361 %!error <Invalid call> ostreamtube (1,2)
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
362 %!error <Invalid call> ostreamtube (1,2,3)
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
363 %!error <Invalid call> ostreamtube (1,2,3,4)
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
364 %!error <Invalid call> ostreamtube (1,2,3,4,5)
3c37ae43996a maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents: 28896
diff changeset
365 %!error <OPTIONS must be a 1- or 2-element> ostreamtube (1,2,3,4,5,6,[1,2,3])
28385
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
366 %!error <SCALE must be a real scalar . 0> ostreamtube (1,2,3,4,5,6,[1i])
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
367 %!error <SCALE must be a real scalar . 0> ostreamtube (1,2,3,4,5,6,[0])
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
368 %!error <N must be greater than 2> ostreamtube (1,2,3,4,5,6,[1,1i])
1888f07317a8 streamtube.m, ostreamtube.m: Minor code cleaning (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents: 28384
diff changeset
369 %!error <N must be greater than 2> ostreamtube (1,2,3,4,5,6,[1,2])