Mercurial > hg > octave-nkf
annotate doc/interpreter/geometry.txi @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 4e15a4c331e7 |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19793
diff
changeset
|
1 @c Copyright (C) 2007-2015 John W. Eaton and David Bateman |
7018 | 2 @c |
3 @c This file is part of Octave. | |
4 @c | |
5 @c Octave is free software; you can redistribute it and/or modify it | |
6 @c under the terms of the GNU General Public License as published by the | |
7 @c Free Software Foundation; either version 3 of the License, or (at | |
8 @c your option) any later version. | |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
9 @c |
7018 | 10 @c Octave is distributed in the hope that it will be useful, but WITHOUT |
11 @c ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 @c FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
13 @c for more details. | |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
14 @c |
7018 | 15 @c You should have received a copy of the GNU General Public License |
16 @c along with Octave; see the file COPYING. If not, see | |
17 @c <http://www.gnu.org/licenses/>. | |
6558 | 18 |
19 @node Geometry | |
20 @chapter Geometry | |
21 | |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
22 Much of the geometry code in Octave is based on the Qhull |
19793
0e1f5a750d00
maint: Periodic merge of gui-release to default.
John W. Eaton <jwe@octave.org>
diff
changeset
|
23 library@footnote{@nospell{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T.}, |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
24 @cite{The Quickhull Algorithm for Convex Hulls}, ACM Trans. on Mathematical |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
25 Software, 22(4):469--483, Dec 1996, @url{http://www.qhull.org}}. |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
26 Some of the documentation for Qhull, particularly for the options that |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
27 can be passed to @code{delaunay}, @code{voronoi} and @code{convhull}, |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
28 etc., is relevant to Octave users. |
6832 | 29 |
6823 | 30 @menu |
31 * Delaunay Triangulation:: | |
32 * Voronoi Diagrams:: | |
33 * Convex Hull:: | |
34 * Interpolation on Scattered Data:: | |
35 @end menu | |
36 | |
37 @node Delaunay Triangulation | |
38 @section Delaunay Triangulation | |
39 | |
6832 | 40 The Delaunay triangulation is constructed from a set of |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
41 circum-circles. These circum-circles are chosen so that there are at |
6832 | 42 least three of the points in the set to triangulation on the |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
43 circumference of the circum-circle. None of the points in the set of |
6832 | 44 points falls within any of the circum-circles. |
45 | |
46 In general there are only three points on the circumference of any | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
47 circum-circle. However, in some cases, and in particular for the |
6832 | 48 case of a regular grid, 4 or more points can be on a single |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
49 circum-circle. In this case the Delaunay triangulation is not unique. |
6832 | 50 |
6823 | 51 @DOCSTRING(delaunay) |
52 | |
19356
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
19232
diff
changeset
|
53 For 3-D inputs @code{delaunay} returns a set of tetrahedra that satisfy the |
6823 | 54 Delaunay circum-circle criteria. Similarly, @code{delaunayn} returns the |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
55 N-dimensional simplex satisfying the Delaunay circum-circle criteria. |
7007 | 56 The N-dimensional extension of a triangulation is called a tessellation. |
6823 | 57 |
58 @DOCSTRING(delaunayn) | |
59 | |
6832 | 60 An example of a Delaunay triangulation of a set of points is |
61 | |
62 @example | |
63 @group | |
64 rand ("state", 2); | |
65 x = rand (10, 1); | |
66 y = rand (10, 1); | |
67 T = delaunay (x, y); | |
68 X = [ x(T(:,1)); x(T(:,2)); x(T(:,3)); x(T(:,1)) ]; | |
69 Y = [ y(T(:,1)); y(T(:,2)); y(T(:,3)); y(T(:,1)) ]; | |
70 axis ([0, 1, 0, 1]); | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
71 plot (X, Y, "b", x, y, "r*"); |
6832 | 72 @end group |
73 @end example | |
74 | |
75 @ifnotinfo | |
76 @noindent | |
77 The result of which can be seen in @ref{fig:delaunay}. | |
78 | |
79 @float Figure,fig:delaunay | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
80 @center @image{delaunay,4in} |
6832 | 81 @caption{Delaunay triangulation of a random set of points} |
82 @end float | |
83 @end ifnotinfo | |
84 | |
6823 | 85 @menu |
6832 | 86 * Plotting the Triangulation:: |
11255
d682cd6669ac
Update info-based documentation menus to include new nodes.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
87 * Identifying Points in Triangulation:: |
6823 | 88 @end menu |
89 | |
6832 | 90 @node Plotting the Triangulation |
91 @subsection Plotting the Triangulation | |
92 | |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
93 Octave has the functions @code{triplot}, @code{trimesh}, and @code{trisurf} |
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
94 to plot the Delaunay triangulation of a 2-dimensional set of points. |
14541
759944521fd6
Improve tetramesh docstring and add function to manual.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
95 @code{tetramesh} will plot the triangulation of a 3-dimensional set of points. |
6832 | 96 |
97 @DOCSTRING(triplot) | |
98 | |
99 @DOCSTRING(trimesh) | |
100 | |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
101 @DOCSTRING(trisurf) |
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
102 |
14541
759944521fd6
Improve tetramesh docstring and add function to manual.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
103 @DOCSTRING(tetramesh) |
759944521fd6
Improve tetramesh docstring and add function to manual.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
104 |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
105 The difference between @code{triplot}, and @code{trimesh} or @code{triplot}, |
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
106 is that the former only plots the 2-dimensional triangulation itself, whereas |
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
107 the second two plot the value of a function @code{f (@var{x}, @var{y})}. An |
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
108 example of the use of the @code{triplot} function is |
6832 | 109 |
110 @example | |
111 @group | |
112 rand ("state", 2) | |
113 x = rand (20, 1); | |
114 y = rand (20, 1); | |
115 tri = delaunay (x, y); | |
116 triplot (tri, x, y); | |
117 @end group | |
118 @end example | |
119 | |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
120 @noindent |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
121 which plots the Delaunay triangulation of a set of random points in |
6832 | 122 2-dimensions. |
123 @ifnotinfo | |
124 The output of the above can be seen in @ref{fig:triplot}. | |
125 | |
126 @float Figure,fig:triplot | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
127 @center @image{triplot,4in} |
6832 | 128 @caption{Delaunay triangulation of a random set of points} |
129 @end float | |
130 @end ifnotinfo | |
131 | |
11255
d682cd6669ac
Update info-based documentation menus to include new nodes.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
132 @node Identifying Points in Triangulation |
d682cd6669ac
Update info-based documentation menus to include new nodes.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
133 @subsection Identifying Points in Triangulation |
6823 | 134 |
135 It is often necessary to identify whether a particular point in the | |
7007 | 136 N-dimensional space is within the Delaunay tessellation of a set of |
8480 | 137 points in this N-dimensional space, and if so which N-simplex contains |
7007 | 138 the point and which point in the tessellation is closest to the desired |
6823 | 139 point. The functions @code{tsearch} and @code{dsearch} perform this |
140 function in a triangulation, and @code{tsearchn} and @code{dsearchn} in | |
7007 | 141 an N-dimensional tessellation. |
6823 | 142 |
143 To identify whether a particular point represented by a vector @var{p} | |
8480 | 144 falls within one of the simplices of an N-simplex, we can write the |
6823 | 145 Cartesian coordinates of the point in a parametric form with respect to |
8480 | 146 the N-simplex. This parametric form is called the Barycentric |
147 Coordinates of the point. If the points defining the N-simplex are given | |
6823 | 148 by @code{@var{N} + 1} vectors @var{t}(@var{i},:), then the Barycentric |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
7984
diff
changeset
|
149 coordinates defining the point @var{p} are given by |
6823 | 150 |
151 @example | |
152 @var{p} = sum (@var{beta}(1:@var{N}+1) * @var{t}(1:@var{N}+1),:) | |
153 @end example | |
154 | |
155 @noindent | |
156 where there are @code{@var{N} + 1} values @code{@var{beta}(@var{i})} | |
157 that together as a vector represent the Barycentric coordinates of the | |
158 point @var{p}. To ensure a unique solution for the values of | |
159 @code{@var{beta}(@var{i})} an additional criteria of | |
160 | |
161 @example | |
162 sum (@var{beta}(1:@var{N}+1)) == 1 | |
163 @end example | |
164 | |
165 @noindent | |
166 is imposed, and we can therefore write the above as | |
167 | |
168 @example | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
169 @group |
6823 | 170 @var{p} - @var{t}(end, :) = @var{beta}(1:end-1) * (@var{t}(1:end-1, :) |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
171 - ones (@var{N}, 1) * @var{t}(end, :) |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
172 @end group |
6823 | 173 @end example |
174 | |
175 @noindent | |
176 Solving for @var{beta} we can then write | |
177 | |
178 @example | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
179 @group |
6823 | 180 @var{beta}(1:end-1) = (@var{p} - @var{t}(end, :)) / (@var{t}(1:end-1, :) |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
181 - ones (@var{N}, 1) * @var{t}(end, :)) |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
182 @var{beta}(end) = sum (@var{beta}(1:end-1)) |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
183 @end group |
6823 | 184 @end example |
185 | |
186 @noindent | |
187 which gives the formula for the conversion of the Cartesian coordinates | |
188 of the point @var{p} to the Barycentric coordinates @var{beta}. An | |
189 important property of the Barycentric coordinates is that for all points | |
8480 | 190 in the N-simplex |
6823 | 191 |
192 @example | |
193 0 <= @var{beta}(@var{i}) <= 1 | |
194 @end example | |
195 | |
196 @noindent | |
197 Therefore, the test in @code{tsearch} and @code{tsearchn} essentially | |
198 only needs to express each point in terms of the Barycentric coordinates | |
8480 | 199 of each of the simplices of the N-simplex and test the values of |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
200 @var{beta}. This is exactly the implementation used in |
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
201 @code{tsearchn}. @code{tsearch} is optimized for 2-dimensions and the |
6823 | 202 Barycentric coordinates are not explicitly formed. |
203 | |
204 @DOCSTRING(tsearch) | |
205 | |
206 @DOCSTRING(tsearchn) | |
207 | |
208 An example of the use of @code{tsearch} can be seen with the simple | |
209 triangulation | |
210 | |
211 @example | |
212 @group | |
213 @var{x} = [-1; -1; 1; 1]; | |
214 @var{y} = [-1; 1; -1; 1]; | |
215 @var{tri} = [1, 2, 3; 2, 3, 1]; | |
216 @end group | |
217 @end example | |
218 | |
219 @noindent | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
220 consisting of two triangles defined by @var{tri}. We can then identify |
6823 | 221 which triangle a point falls in like |
222 | |
223 @example | |
224 @group | |
225 tsearch (@var{x}, @var{y}, @var{tri}, -0.5, -0.5) | |
226 @result{} 1 | |
227 tsearch (@var{x}, @var{y}, @var{tri}, 0.5, 0.5) | |
228 @result{} 2 | |
229 @end group | |
230 @end example | |
231 | |
232 @noindent | |
233 and we can confirm that a point doesn't lie within one of the triangles like | |
234 | |
235 @example | |
236 @group | |
237 tsearch (@var{x}, @var{y}, @var{tri}, 2, 2) | |
238 @result{} NaN | |
239 @end group | |
240 @end example | |
241 | |
242 The @code{dsearch} and @code{dsearchn} find the closest point in a | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
243 tessellation to the desired point. The desired point does not |
6823 | 244 necessarily have to be in the tessellation, and even if it the returned |
6832 | 245 point of the tessellation does not have to be one of the vertexes of the |
6823 | 246 N-simplex within which the desired point is found. |
247 | |
248 @DOCSTRING(dsearch) | |
249 | |
250 @DOCSTRING(dsearchn) | |
251 | |
252 An example of the use of @code{dsearch}, using the above values of | |
253 @var{x}, @var{y} and @var{tri} is | |
254 | |
255 @example | |
256 @group | |
257 dsearch (@var{x}, @var{y}, @var{tri}, -2, -2) | |
258 @result{} 1 | |
259 @end group | |
260 @end example | |
261 | |
262 If you wish the points that are outside the tessellation to be flagged, | |
263 then @code{dsearchn} can be used as | |
264 | |
265 @example | |
266 @group | |
267 dsearchn ([@var{x}, @var{y}], @var{tri}, [-2, -2], NaN) | |
268 @result{} NaN | |
269 dsearchn ([@var{x}, @var{y}], @var{tri}, [-0.5, -0.5], NaN) | |
270 @result{} 1 | |
271 @end group | |
272 @end example | |
273 | |
274 @noindent | |
275 where the point outside the tessellation are then flagged with @code{NaN}. | |
276 | |
277 @node Voronoi Diagrams | |
278 @section Voronoi Diagrams | |
279 | |
280 A Voronoi diagram or Voronoi tessellation of a set of points @var{s} in | |
281 an N-dimensional space, is the tessellation of the N-dimensional space | |
282 such that all points in @code{@var{v}(@var{p})}, a partitions of the | |
283 tessellation where @var{p} is a member of @var{s}, are closer to @var{p} | |
284 than any other point in @var{s}. The Voronoi diagram is related to the | |
6832 | 285 Delaunay triangulation of a set of points, in that the vertexes of the |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
286 Voronoi tessellation are the centers of the circum-circles of the |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
287 simplices of the Delaunay tessellation. |
6823 | 288 |
289 @DOCSTRING(voronoi) | |
290 | |
291 @DOCSTRING(voronoin) | |
292 | |
6832 | 293 An example of the use of @code{voronoi} is |
294 | |
295 @example | |
296 @group | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
297 rand ("state",9); |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
298 x = rand (10,1); |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
299 y = rand (10,1); |
6832 | 300 tri = delaunay (x, y); |
301 [vx, vy] = voronoi (x, y, tri); | |
302 triplot (tri, x, y, "b"); | |
303 hold on; | |
304 plot (vx, vy, "r"); | |
305 @end group | |
306 @end example | |
307 | |
308 @ifnotinfo | |
309 @noindent | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
310 The result of which can be seen in @ref{fig:voronoi}. Note that the |
6832 | 311 circum-circle of one of the triangles has been added to this figure, to |
312 make the relationship between the Delaunay tessellation and the Voronoi | |
313 diagram clearer. | |
314 | |
315 @float Figure,fig:voronoi | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
316 @center @image{voronoi,4in} |
6832 | 317 @caption{Delaunay triangulation and Voronoi diagram of a random set of points} |
318 @end float | |
319 @end ifnotinfo | |
320 | |
6847 | 321 Additional information about the size of the facets of a Voronoi |
322 diagram, and which points of a set of points is in a polygon can be had | |
323 with the @code{polyarea} and @code{inpolygon} functions respectively. | |
6832 | 324 |
325 @DOCSTRING(polyarea) | |
326 | |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
327 An example of the use of @code{polyarea} might be |
6832 | 328 |
329 @example | |
330 @group | |
331 rand ("state", 2); | |
332 x = rand (10, 1); | |
333 y = rand (10, 1); | |
334 [c, f] = voronoin ([x, y]); | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
335 af = zeros (size (f)); |
6832 | 336 for i = 1 : length (f) |
337 af(i) = polyarea (c (f @{i, :@}, 1), c (f @{i, :@}, 2)); | |
338 endfor | |
339 @end group | |
340 @end example | |
341 | |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
342 Facets of the Voronoi diagram with a vertex at infinity have infinity |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
343 area. A simplified version of @code{polyarea} for rectangles is |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
344 available with @code{rectint} |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
345 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
346 @DOCSTRING(rectint) |
6832 | 347 |
6847 | 348 @DOCSTRING(inpolygon) |
349 | |
350 An example of the use of @code{inpolygon} might be | |
351 | |
352 @example | |
353 @group | |
354 randn ("state", 2); | |
355 x = randn (100, 1); | |
356 y = randn (100, 1); | |
357 vx = cos (pi * [-1 : 0.1: 1]); | |
358 vy = sin (pi * [-1 : 0.1 : 1]); | |
359 in = inpolygon (x, y, vx, vy); | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
360 plot (vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo"); |
6847 | 361 axis ([-2, 2, -2, 2]); |
362 @end group | |
363 @end example | |
364 | |
365 @ifnotinfo | |
366 @noindent | |
367 The result of which can be seen in @ref{fig:inpolygon}. | |
368 | |
369 @float Figure,fig:inpolygon | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
370 @center @image{inpolygon,4in} |
6847 | 371 @caption{Demonstration of the @code{inpolygon} function to determine the |
372 points inside a polygon} | |
373 @end float | |
374 @end ifnotinfo | |
375 | |
6823 | 376 @node Convex Hull |
377 @section Convex Hull | |
378 | |
7001 | 379 The convex hull of a set of points is the minimum convex envelope |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
380 containing all of the points. Octave has the functions @code{convhull} |
7007 | 381 and @code{convhulln} to calculate the convex hull of 2-dimensional and |
6832 | 382 N-dimensional sets of points. |
383 | |
6823 | 384 @DOCSTRING(convhull) |
385 | |
386 @DOCSTRING(convhulln) | |
387 | |
6832 | 388 An example of the use of @code{convhull} is |
6823 | 389 |
6832 | 390 @example |
391 @group | |
392 x = -3:0.05:3; | |
393 y = abs (sin (x)); | |
394 k = convhull (x, y); | |
395 plot (x(k), y(k), "r-", x, y, "b+"); | |
396 axis ([-3.05, 3.05, -0.05, 1.05]); | |
397 @end group | |
398 @end example | |
6823 | 399 |
6832 | 400 @ifnotinfo |
401 @noindent | |
402 The output of the above can be seen in @ref{fig:convhull}. | |
6823 | 403 |
6832 | 404 @float Figure,fig:convhull |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
405 @center @image{convhull,4in} |
6832 | 406 @caption{The convex hull of a simple set of points} |
407 @end float | |
408 @end ifnotinfo | |
6823 | 409 |
410 @node Interpolation on Scattered Data | |
411 @section Interpolation on Scattered Data | |
412 | |
6832 | 413 An important use of the Delaunay tessellation is that it can be used to |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
414 interpolate from scattered data to an arbitrary set of points. To do |
6832 | 415 this the N-simplex of the known set of points is calculated with |
19356
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
19232
diff
changeset
|
416 @code{delaunay} or @code{delaunayn}. Then the simplices in to which the |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
19232
diff
changeset
|
417 desired points are found are identified. Finally the vertices of the simplices |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
19232
diff
changeset
|
418 are used to interpolate to the desired points. The functions that perform this |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
19232
diff
changeset
|
419 interpolation are @code{griddata}, @code{griddata3} and @code{griddatan}. |
6832 | 420 |
6823 | 421 @DOCSTRING(griddata) |
422 | |
423 @DOCSTRING(griddata3) | |
424 | |
425 @DOCSTRING(griddatan) | |
6832 | 426 |
427 An example of the use of the @code{griddata} function is | |
428 | |
429 @example | |
430 @group | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
431 rand ("state", 1); |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
432 x = 2*rand (1000,1) - 1; |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
433 y = 2*rand (size (x)) - 1; |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
434 z = sin (2*(x.^2+y.^2)); |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
435 [xx,yy] = meshgrid (linspace (-1,1,32)); |
20425
4e15a4c331e7
doc: Fix griddata example to new calling convention
Mike Miller <mtmiller@octave.org>
parents:
19898
diff
changeset
|
436 zz = griddata (x, y, z, xx, yy); |
4e15a4c331e7
doc: Fix griddata example to new calling convention
Mike Miller <mtmiller@octave.org>
parents:
19898
diff
changeset
|
437 mesh (xx, yy, zz); |
6832 | 438 @end group |
439 @end example | |
440 | |
441 @noindent | |
19793
0e1f5a750d00
maint: Periodic merge of gui-release to default.
John W. Eaton <jwe@octave.org>
diff
changeset
|
442 that interpolates from a random scattering of points, to a uniform grid. |
6832 | 443 @ifnotinfo |
444 The output of the above can be seen in @ref{fig:griddata}. | |
445 | |
446 @float Figure,fig:griddata | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
447 @center @image{griddata,4in} |
6832 | 448 @caption{Interpolation from a scattered data to a regular grid} |
449 @end float | |
450 @end ifnotinfo |