Mercurial > octave
annotate scripts/plot/draw/streamribbon.m @ 32632:2e484f9f1f18 stable
maint: update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 22 Dec 2023 12:08:17 -0500 |
parents | 597f3ee61a48 |
children |
rev | line source |
---|---|
28386
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
1 ######################################################################## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
2 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
3 ## Copyright (C) 2020-2024 The Octave Project Developers |
28386
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
4 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
7 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
8 ## This file is part of Octave. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
9 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
11 ## under the terms of the GNU General Public License as published by |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
13 ## (at your option) any later version. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
14 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
15 ## Octave is distributed in the hope that it will be useful, but |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
18 ## GNU General Public License for more details. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
19 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
20 ## You should have received a copy of the GNU General Public License |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
21 ## along with Octave; see the file COPYING. If not, see |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
23 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
24 ######################################################################## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
25 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
26 ## -*- texinfo -*- |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
27 ## @deftypefn {} {} streamribbon (@var{x}, @var{y}, @var{z}, @var{u}, @var{v}, @var{w}, @var{sx}, @var{sy}, @var{sz}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
28 ## @deftypefnx {} {} streamribbon (@var{u}, @var{v}, @var{w}, @var{sx}, @var{sy}, @var{sz}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
29 ## @deftypefnx {} {} streamribbon (@var{xyz}, @var{x}, @var{y}, @var{z}, @var{anlr_spd}, @var{lin_spd}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
30 ## @deftypefnx {} {} streamribbon (@var{xyz}, @var{anlr_spd}, @var{lin_spd}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
31 ## @deftypefnx {} {} streamribbon (@var{xyz}, @var{anlr_rot}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
32 ## @deftypefnx {} {} streamribbon (@dots{}, @var{width}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
33 ## @deftypefnx {} {} streamribbon (@var{hax}, @dots{}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
34 ## @deftypefnx {} {@var{h} =} streamribbon (@dots{}) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
35 ## Calculate and display streamribbons. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
36 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
37 ## The streamribbon is constructed by rotating a normal vector around a |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
38 ## streamline according to the angular rotation of the vector field. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
39 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
40 ## The vector field is given by @code{[@var{u}, @var{v}, @var{w}]} and is |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
41 ## defined over a rectangular grid given by @code{[@var{x}, @var{y}, @var{z}]}. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
42 ## The streamribbons start at the seed points |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
43 ## @code{[@var{sx}, @var{sy}, @var{sz}]}. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
44 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
45 ## @code{streamribbon} can be called with a cell array that contains |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
46 ## pre-computed streamline data. To do this, @var{xyz} must be created with |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
47 ## the @code{stream3} function. @var{lin_spd} is the linear speed of the |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
48 ## vector field and can be calculated from @code{[@var{u}, @var{v}, @var{w}]} |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
49 ## by the square root of the sum of the squares. The angular speed |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
50 ## @var{anlr_spd} is the projection of the angular velocity onto the velocity |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
51 ## of the normalized vector field and can be calculated with the @code{curl} |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
52 ## command. This option is useful if you need to alter the integrator step |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
53 ## size or the maximum number of streamline vertices. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
54 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
55 ## Alternatively, ribbons can be created from an array of vertices @var{xyz} of |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
56 ## a path curve. @var{anlr_rot} contains the angles of rotation around the |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
57 ## edges between adjacent vertices of the path curve. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
58 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
59 ## The input parameter @var{width} sets the width of the streamribbons. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
60 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
61 ## Streamribbons are colored according to the total angle of rotation along the |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
62 ## ribbon. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
63 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
64 ## If the first argument @var{hax} is an axes handle, then plot into this axes, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
65 ## rather than the current axes returned by @code{gca}. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
66 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
67 ## The optional return value @var{h} is a graphics handle to the plot objects |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
68 ## created for each streamribbon. |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
69 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
70 ## Example: |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
71 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
72 ## @example |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
73 ## @group |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
74 ## [x, y, z] = meshgrid (0:0.2:4, -1:0.2:1, -1:0.2:1); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
75 ## u = - x + 10; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
76 ## v = 10 * z.*x; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
77 ## w = - 10 * y.*x; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
78 ## streamribbon (x, y, z, u, v, w, [0, 0], [0, 0.6], [0, 0]); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
79 ## view (3); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
80 ## @end group |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
81 ## @end example |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
82 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
83 ## @seealso{streamline, stream3, streamtube, ostreamtube} |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
84 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
85 ## @end deftypefn |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
86 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
87 ## References: |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
88 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
89 ## @inproceedings{ |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
90 ## title = {Feature Detection from Vector Quantities in a Numerically Simulated Hypersonic Flow Field in Combination with Experimental Flow Visualization}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
91 ## author = {Pagendarm, Hans-Georg and Walter, Birgit}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
92 ## year = {1994}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
93 ## publisher = {IEEE Computer Society Press}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
94 ## booktitle = {Proceedings of the Conference on Visualization ’94}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
95 ## pages = {117–123}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
96 ## } |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
97 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
98 ## @article{ |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
99 ## title = {Efficient streamline, streamribbon, and streamtube constructions on unstructured grids}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
100 ## author = {Ueng, Shyh-Kuang and Sikorski, C. and Ma, Kwan-Liu}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
101 ## year = {1996}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
102 ## month = {June}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
103 ## publisher = {IEEE Transactions on Visualization and Computer Graphics}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
104 ## } |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
105 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
106 ## @inproceedings{ |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
107 ## title = {Visualization of 3-D vector fields - Variations on a stream}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
108 ## author = {Dave Darmofal and Robert Haimes}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
109 ## year = {1992} |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
110 ## } |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
111 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
112 ## @techreport{ |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
113 ## title = {Parallel Transport Approach to Curve Framing}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
114 ## author = {Andrew J. Hanson and Hui Ma}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
115 ## year = {1995} |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
116 ## } |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
117 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
118 ## @article{ |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
119 ## title = {There is More than One Way to Frame a Curve}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
120 ## author = {Bishop, Richard}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
121 ## year = {1975}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
122 ## month = {03}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
123 ## volume = {82}, |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
124 ## publisher = {The American Mathematical Monthly} |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
125 ## } |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
126 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
127 function h = streamribbon (varargin) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
128 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
129 [hax, varargin, nargin] = __plt_get_axis_arg__ ("streamribbon", varargin{:}); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
130 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
131 width = []; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
132 xyz = []; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
133 anlr_spd = []; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
134 lin_spd = []; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
135 anlr_rot = []; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
136 switch (nargin) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
137 case 2 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
138 [xyz, anlr_rot] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
139 case 3 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
140 if (numel (varargin{3}) == 1) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
141 [xyz, anlr_rot, width] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
142 else |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
143 [xyz, anlr_spd, lin_spd] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
144 [m, n, p] = size (anlr_spd); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
145 [x, y, z] = meshgrid (1:n, 1:m, 1:p); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
146 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
147 case 4 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
148 [xyz, anlr_spd, lin_spd, width] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
149 [m, n, p] = size (anlr_spd); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
150 [x, y, z] = meshgrid (1:n, 1:m, 1:p); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
151 case 6 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
152 if (iscell (varargin{1})) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
153 [xyz, x, y, z, anlr_spd, lin_spd] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
154 else |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
155 [u, v, w, spx, spy, spz] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
156 [m, n, p] = size (u); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
157 [x, y, z] = meshgrid (1:n, 1:m, 1:p); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
158 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
159 case 7 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
160 if (iscell (varargin{1})) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
161 [xyz, x, y, z, anlr_spd, lin_spd, width] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
162 else |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
163 [u, v, w, spx, spy, spz, width] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
164 [m, n, p] = size (u); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
165 [x, y, z] = meshgrid (1:n, 1:m, 1:p); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
166 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
167 case 9 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
168 [x, y, z, u, v, w, spx, spy, spz] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
169 case 10 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
170 [x, y, z, u, v, w, spx, spy, spz, width] = varargin{:}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
171 otherwise |
28901
3c37ae43996a
maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
172 print_usage (); |
28386
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
173 endswitch |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
174 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
175 if (isempty (xyz)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
176 xyz = stream3 (x, y, z, u, v, w, spx, spy, spz); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
177 anlr_spd = curl (x, y, z, u, v, w); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
178 lin_spd = sqrt (u.*u + v.*v + w.*w); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
179 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
180 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
181 ## Derive scale factor from the bounding box diagonal |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
182 if (isempty (width)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
183 mxx = mnx = mxy = mny = mxz = mnz = []; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
184 j = 1; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
185 for i = 1 : length (xyz) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
186 sl = xyz{i}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
187 if (! isempty (sl)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
188 slx = sl(:,1); sly = sl(:,2); slz = sl(:,3); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
189 mxx(j) = max (slx); mnx(j) = min (slx); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
190 mxy(j) = max (sly); mny(j) = min (sly); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
191 mxz(j) = max (slz); mnz(j) = min (slz); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
192 j += 1; |
28947
b73a54c31152
maint: Use Octave-specific end keywords rather than just 'end'.
Rik <rik@octave.org>
parents:
28931
diff
changeset
|
193 endif |
28386
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
194 endfor |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
195 dx = max (mxx) - min (mnx); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
196 dy = max (mxy) - min (mny); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
197 dz = max (mxz) - min (mnz); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
198 width = sqrt (dx*dx + dy*dy + dz*dz) / 25; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
199 elseif (! isreal (width) || width <= 0) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
200 error ("streamribbon: WIDTH must be a real scalar > 0"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
201 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
202 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
203 if (! isempty (anlr_rot)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
204 for i = 1 : length (xyz) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
205 if (rows (anlr_rot{i}) != rows (xyz{i})) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
206 error ("streamribbon: ANLR_ROT must have same length as XYZ"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
207 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
208 endfor |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
209 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
210 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
211 if (isempty (hax)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
212 hax = gca (); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
213 else |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
214 hax = hax(1); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
215 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
216 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
217 ## Angular speed of a paddle wheel spinning around a streamline in a fluid |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
218 ## flow "V": |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
219 ## dtheta/dt = 0.5 * <curl(V), V/norm(V)> |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
220 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
221 ## Integration along a streamline segment with the length "h" yields the |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
222 ## rotation angle: |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
223 ## theta = 0.25 * h * <curl(V), V(0)/norm(V(0))^2) + V(h)/norm(V(h))^2)> |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
224 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
225 ## Alternative approach using the curl angular speed "c = curl()": |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
226 ## theta = 0.5 * h * (c(0)/norm(V(0)) + c(h)/norm(V(h))) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
227 ## |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
228 ## Hints: |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
229 ## i. ) For integration use trapezoidal rule |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
230 ## ii.) "V" can be assumend to be piecewise linear and curl(V) to be |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
231 ## piecewise constant because of the used linear interpolation |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
232 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
233 h = []; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
234 for i = 1 : length (xyz) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
235 sl = xyz{i}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
236 num_vertices = rows (sl); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
237 if (! isempty (sl) && num_vertices > 1) |
28921
967cfcde2e35
maint: Use parentheses around conditional expressions.
Rik <rik@octave.org>
parents:
28901
diff
changeset
|
238 if (isempty (anlr_rot)) |
28386
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
239 ## Plot from vector field |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
240 ## Interpolate onto streamline vertices |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
241 [lin_spd_sl, anlr_spd_sl, max_vertices] = ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
242 interp_sl (x, y, z, lin_spd, anlr_spd, sl); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
243 if (max_vertices > 1) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
244 ## Euclidean distance between two adjacent vertices |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
245 stepsize = vecnorm (diff (sl(1:max_vertices, :)), 2, 2); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
246 ## Angular rotation around edges between two adjacent sl-vertices |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
247 ## Note: Potential "division by zero" is checked in interp_sl() |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
248 anlr_rot_sl = 0.5 * stepsize.*(anlr_spd_sl(1:max_vertices - 1)./ ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
249 lin_spd_sl(1:max_vertices - 1) + ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
250 anlr_spd_sl(2:max_vertices)./ ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
251 lin_spd_sl(2:max_vertices)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
252 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
253 htmp = plotribbon (hax, sl, anlr_rot_sl, max_vertices, 0.5 * width); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
254 h = [h; htmp]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
255 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
256 else |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
257 ## Plot from vertice array |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
258 anlr_rot_sl = anlr_rot{i}; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
259 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
260 htmp = plotribbon (hax, sl, anlr_rot_sl, num_vertices, 0.5 * width); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
261 h = [h; htmp]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
262 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
263 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
264 endfor |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
265 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
266 endfunction |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
267 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
268 function h = plotribbon (hax, sl, anlr_rot_sl, max_vertices, width2) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
269 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
270 total_angle = cumsum (anlr_rot_sl); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
271 total_angle = [0; total_angle]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
272 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
273 ## 1st streamline segment |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
274 X0 = sl(1,:); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
275 X1 = sl(2,:); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
276 R = X1 - X0; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
277 RE = R / norm (R); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
278 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
279 ## Initial vector KE which is to be transported along the vertice array |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
280 KE = get_normal2 (RE); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
281 XS10 = - width2 * KE + X0; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
282 XS20 = width2 * KE + X0; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
283 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
284 ## Apply angular rotation |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
285 cp = cos (anlr_rot_sl(1)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
286 sp = sin (anlr_rot_sl(1)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
287 KE = rotation (KE, RE, cp, sp).'; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
288 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
289 XS1 = - width2 * KE + X1; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
290 XS2 = width2 * KE + X1; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
291 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
292 px = zeros (2, max_vertices); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
293 py = zeros (2, max_vertices); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
294 pz = zeros (2, max_vertices); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
295 pc = zeros (2, max_vertices); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
296 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
297 px(:,1) = [XS10(1); XS20(1)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
298 py(:,1) = [XS10(2); XS20(2)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
299 pz(:,1) = [XS10(3); XS20(3)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
300 pc(:,1) = total_angle(1) * [1; 1]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
301 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
302 px(:,2) = [XS1(1); XS2(1)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
303 py(:,2) = [XS1(2); XS2(2)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
304 pz(:,2) = [XS1(3); XS2(3)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
305 pc(:,2) = total_angle(2) * [1; 1]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
306 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
307 for i = 3 : max_vertices |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
308 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
309 ## Next streamline segment |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
310 X0 = X1; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
311 X1 = sl(i,:); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
312 R = X1 - X0; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
313 RE = R / norm (R); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
314 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
315 ## Project KE onto RE and get the difference in order to transport |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
316 ## the normal vector KE along the vertex array |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
317 Kp = KE - RE * dot (KE, RE); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
318 KE = Kp / norm (Kp); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
319 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
320 ## Apply angular rotation to KE |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
321 cp = cos (anlr_rot_sl(i - 1)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
322 sp = sin (anlr_rot_sl(i - 1)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
323 KE = rotation (KE, RE, cp, sp).'; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
324 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
325 XS1 = - width2 * KE + X1; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
326 XS2 = width2 * KE + X1; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
327 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
328 px(:,i) = [XS1(1); XS2(1)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
329 py(:,i) = [XS1(2); XS2(2)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
330 pz(:,i) = [XS1(3); XS2(3)]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
331 pc(:,i) = total_angle(i) * [1; 1]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
332 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
333 endfor |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
334 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
335 h = surface (hax, px, py, pz, pc); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
336 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
337 endfunction |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
338 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
339 ## Interpolate speed and divergence onto the streamline vertices and |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
340 ## return the first chunck of valid samples until a singularity / |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
341 ## zero is hit or the streamline vertex array "sl" ends |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
342 function [lin_spd_sl, anlr_spd_sl, max_vertices] = ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
343 interp_sl (x, y, z, lin_spd, anlr_spd, sl) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
344 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
345 anlr_spd_sl = interp3 (x, y, z, anlr_spd, sl(:,1), sl(:,2), sl(:,3)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
346 lin_spd_sl = interp3 (x, y, z, lin_spd, sl(:,1), sl(:,2), sl(:,3)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
347 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
348 is_singular_anlr_spd = find (isnan (anlr_spd_sl), 1, "first"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
349 is_zero_lin_spd = find (lin_spd_sl == 0, 1, "first"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
350 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
351 max_vertices = rows (sl); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
352 if (! isempty (is_singular_anlr_spd)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
353 max_vertices = min (max_vertices, is_singular_anlr_spd - 1); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
354 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
355 if (! isempty (is_zero_lin_spd)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
356 max_vertices = min (max_vertices, is_zero_lin_spd - 1); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
357 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
358 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
359 endfunction |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
360 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
361 ## N normal to X, so that N is in span ([0 0 1], X) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
362 ## If not possible then span ([1 0 0], X) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
363 function N = get_normal2 (X) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
364 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
365 if ((X(1) == 0) && (X(2) == 0)) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
366 A = [1, 0, 0]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
367 else |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
368 A = [0, 0, 1]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
369 endif |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
370 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
371 ## Project A onto X and get the difference |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
372 N = A - X * dot (A, X) / (norm (X)^2); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
373 N /= norm (N); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
374 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
375 endfunction |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
376 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
377 ## Rotate X around U where |U| = 1 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
378 ## cp = cos (angle), sp = sin (angle) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
379 function Y = rotation (X, U, cp, sp) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
380 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
381 ux = U(1); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
382 uy = U(2); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
383 uz = U(3); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
384 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
385 Y(1,:) = X(1) * (cp + ux * ux * (1 - cp)) + ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
386 X(2) * (ux * uy * (1 - cp) - uz * sp) + ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
387 X(3) * (ux * uz * (1 - cp) + uy * sp); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
388 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
389 Y(2,:) = X(1) * (uy * ux * (1 - cp) + uz * sp) + ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
390 X(2) * (cp + uy * uy * (1 - cp)) + ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
391 X(3) * (uy * uz * (1 - cp) - ux * sp); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
392 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
393 Y(3,:) = X(1) * (uz * ux * (1 - cp) - uy * sp) + ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
394 X(2) * (uz * uy * (1 - cp) + ux * sp) + ... |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
395 X(3) * (cp + uz * uz * (1 - cp)); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
396 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
397 endfunction |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
398 |
28931
c5b1bbb95a66
maint: start %!demo or %!test blocks 2 newlines after endfunction.
Rik <rik@octave.org>
parents:
28921
diff
changeset
|
399 |
28386
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
400 %!demo |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
401 %! clf; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
402 %! [x, y, z] = meshgrid (0:0.2:4, -1:0.2:1, -1:0.2:1); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
403 %! u = - x + 10; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
404 %! v = 10 * z.*x; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
405 %! w = - 10 * y.*x; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
406 %! sx = [0, 0]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
407 %! sy = [0, 0.6]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
408 %! sz = [0, 0]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
409 %! streamribbon (x, y, z, u, v, w, sx, sy, sz); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
410 %! hold on; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
411 %! quiver3 (x, y, z, u, v, w); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
412 %! colormap (jet); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
413 %! shading interp; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
414 %! camlight ("headlight"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
415 %! view (3); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
416 %! axis tight equal off; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
417 %! set (gca, "cameraviewanglemode", "manual"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
418 %! hcb = colorbar; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
419 %! title (hcb, "Angle"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
420 %! title ("Streamribbon"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
421 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
422 %!demo |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
423 %! clf; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
424 %! t = (0:pi/50:2*pi).'; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
425 %! xyz{1} = [cos(t), sin(t), 0*t]; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
426 %! twist{1} = ones (numel (t), 1) * pi / (numel (t) - 1); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
427 %! streamribbon (xyz, twist, 0.5); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
428 %! colormap (jet); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
429 %! view (3); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
430 %! camlight ("headlight"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
431 %! axis tight equal off; |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
432 %! title ("Moebius Strip"); |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
433 |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
434 ## 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
|
435 %!error <Invalid call> streamribbon () |
28901
3c37ae43996a
maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
436 %!error <Invalid call> streamribbon (1) |
3c37ae43996a
maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
437 %!error <Invalid call> streamribbon (1,2,3,4,5) |
3c37ae43996a
maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
438 %!error <Invalid call> streamribbon (1,2,3,4,5,6,7,8) |
3c37ae43996a
maint: Code cleanup associated with varargin checking.
Rik <rik@octave.org>
parents:
28896
diff
changeset
|
439 %!error <Invalid call> streamribbon (1,2,3,4,5,6,7,8,9,10,11) |
28386
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
440 %!error <WIDTH must be a real scalar . 0> streamribbon (1,2,3,1i) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
441 %!error <WIDTH must be a real scalar . 0> streamribbon (1,2,3,0) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
442 %!error <WIDTH must be a real scalar . 0> streamribbon (1,2,3,-1) |
8a9a041db1dc
Add "streamribbon" function (patch #9916).
Markus Meisinger <chloros2@gmx.de>
parents:
diff
changeset
|
443 %!error <ANLR_ROT must have same length as XYZ> streamribbon ({[1,1,1;2,2,2]},{[1,1,1]}) |