Mercurial > hg > octave-nkf
annotate doc/interpreter/geometry.txi @ 16828:ddac88d32d6a
Make demos in plot m-files compatible with Matlab for running comparison script.
* scripts/plot/isosurface.m, scripts/plot/line.m, scripts/plot/mesh.m,
scripts/plot/plotyy.m, scripts/plot/printd.m, scripts/plot/semilogy.m,
scripts/plot/shrinkfaces.m, scripts/plot/stairs.m, scripts/plot/stem.m,
scripts/plot/stemleaf.m, scripts/plot/tetramesh.m: Replace double quote (")
with single quote ('). Use '%' for comment character. Use '...' for
line continuation.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 23 Jun 2013 14:47:05 -0700 |
parents | c3fd61c59e9c |
children | d63878346099 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
12187
diff
changeset
|
1 @c Copyright (C) 2007-2012 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. | |
9 @c | |
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. | |
14 @c | |
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 | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
22 Much of the geometry code in Octave is based on the Qhull |
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
23 library@footnote{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9906
diff
changeset
|
24 @cite{The Quickhull Algorithm for Convex Hulls}, ACM Trans. on Mathematical |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
25 Software, 22(4):469--483, Dec 1996, @url{http://www.qhull.org}}. |
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
26 Some of the documentation for Qhull, particularly for the options that |
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
27 can be passed to @code{delaunay}, @code{voronoi} and @code{convhull}, |
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 |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
49 circum-circle. In this case the Delaunay triangulation is not unique. |
6832 | 50 |
6823 | 51 @DOCSTRING(delaunay) |
52 | |
53 The 3- and N-dimensional extension of the Delaunay triangulation are | |
54 given by @code{delaunay3} and @code{delaunayn} respectively. | |
55 @code{delaunay3} returns a set of tetrahedra that satisfy the | |
56 Delaunay circum-circle criteria. Similarly, @code{delaunayn} returns the | |
57 N-dimensional simplex satisfying the Delaunay circum-circle criteria. | |
7007 | 58 The N-dimensional extension of a triangulation is called a tessellation. |
6823 | 59 |
60 @DOCSTRING(delaunay3) | |
61 | |
62 @DOCSTRING(delaunayn) | |
63 | |
6832 | 64 An example of a Delaunay triangulation of a set of points is |
65 | |
66 @example | |
67 @group | |
68 rand ("state", 2); | |
69 x = rand (10, 1); | |
70 y = rand (10, 1); | |
71 T = delaunay (x, y); | |
72 X = [ x(T(:,1)); x(T(:,2)); x(T(:,3)); x(T(:,1)) ]; | |
73 Y = [ y(T(:,1)); y(T(:,2)); y(T(:,3)); y(T(:,1)) ]; | |
74 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
|
75 plot (X, Y, "b", x, y, "r*"); |
6832 | 76 @end group |
77 @end example | |
78 | |
79 @ifnotinfo | |
80 @noindent | |
81 The result of which can be seen in @ref{fig:delaunay}. | |
82 | |
83 @float Figure,fig:delaunay | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
84 @center @image{delaunay,4in} |
6832 | 85 @caption{Delaunay triangulation of a random set of points} |
86 @end float | |
87 @end ifnotinfo | |
88 | |
6823 | 89 @menu |
6832 | 90 * Plotting the Triangulation:: |
11255
d682cd6669ac
Update info-based documentation menus to include new nodes.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
91 * Identifying Points in Triangulation:: |
6823 | 92 @end menu |
93 | |
6832 | 94 @node Plotting the Triangulation |
95 @subsection Plotting the Triangulation | |
96 | |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
97 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
|
98 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
|
99 @code{tetramesh} will plot the triangulation of a 3-dimensional set of points. |
6832 | 100 |
101 @DOCSTRING(triplot) | |
102 | |
103 @DOCSTRING(trimesh) | |
104 | |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
105 @DOCSTRING(trisurf) |
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
106 |
14541
759944521fd6
Improve tetramesh docstring and add function to manual.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
107 @DOCSTRING(tetramesh) |
759944521fd6
Improve tetramesh docstring and add function to manual.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
108 |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 example of the use of the @code{triplot} function is |
6832 | 113 |
114 @example | |
115 @group | |
116 rand ("state", 2) | |
117 x = rand (20, 1); | |
118 y = rand (20, 1); | |
119 tri = delaunay (x, y); | |
120 triplot (tri, x, y); | |
121 @end group | |
122 @end example | |
123 | |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
124 @noindent |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
125 which plots the Delaunay triangulation of a set of random points in |
6832 | 126 2-dimensions. |
127 @ifnotinfo | |
128 The output of the above can be seen in @ref{fig:triplot}. | |
129 | |
130 @float Figure,fig:triplot | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
131 @center @image{triplot,4in} |
6832 | 132 @caption{Delaunay triangulation of a random set of points} |
133 @end float | |
134 @end ifnotinfo | |
135 | |
11255
d682cd6669ac
Update info-based documentation menus to include new nodes.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
136 @node Identifying Points in Triangulation |
d682cd6669ac
Update info-based documentation menus to include new nodes.
Rik <octave@nomad.inbox5.com>
parents:
10846
diff
changeset
|
137 @subsection Identifying Points in Triangulation |
6823 | 138 |
139 It is often necessary to identify whether a particular point in the | |
7007 | 140 N-dimensional space is within the Delaunay tessellation of a set of |
8480 | 141 points in this N-dimensional space, and if so which N-simplex contains |
7007 | 142 the point and which point in the tessellation is closest to the desired |
6823 | 143 point. The functions @code{tsearch} and @code{dsearch} perform this |
144 function in a triangulation, and @code{tsearchn} and @code{dsearchn} in | |
7007 | 145 an N-dimensional tessellation. |
6823 | 146 |
147 To identify whether a particular point represented by a vector @var{p} | |
8480 | 148 falls within one of the simplices of an N-simplex, we can write the |
6823 | 149 Cartesian coordinates of the point in a parametric form with respect to |
8480 | 150 the N-simplex. This parametric form is called the Barycentric |
151 Coordinates of the point. If the points defining the N-simplex are given | |
6823 | 152 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
|
153 coordinates defining the point @var{p} are given by |
6823 | 154 |
155 @example | |
156 @var{p} = sum (@var{beta}(1:@var{N}+1) * @var{t}(1:@var{N}+1),:) | |
157 @end example | |
158 | |
159 @noindent | |
160 where there are @code{@var{N} + 1} values @code{@var{beta}(@var{i})} | |
161 that together as a vector represent the Barycentric coordinates of the | |
162 point @var{p}. To ensure a unique solution for the values of | |
163 @code{@var{beta}(@var{i})} an additional criteria of | |
164 | |
165 @example | |
166 sum (@var{beta}(1:@var{N}+1)) == 1 | |
167 @end example | |
168 | |
169 @noindent | |
170 is imposed, and we can therefore write the above as | |
171 | |
172 @example | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
173 @group |
6823 | 174 @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
|
175 - 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
|
176 @end group |
6823 | 177 @end example |
178 | |
179 @noindent | |
180 Solving for @var{beta} we can then write | |
181 | |
182 @example | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
183 @group |
6823 | 184 @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
|
185 - 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
|
186 @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
|
187 @end group |
6823 | 188 @end example |
189 | |
190 @noindent | |
191 which gives the formula for the conversion of the Cartesian coordinates | |
192 of the point @var{p} to the Barycentric coordinates @var{beta}. An | |
193 important property of the Barycentric coordinates is that for all points | |
8480 | 194 in the N-simplex |
6823 | 195 |
196 @example | |
197 0 <= @var{beta}(@var{i}) <= 1 | |
198 @end example | |
199 | |
200 @noindent | |
201 Therefore, the test in @code{tsearch} and @code{tsearchn} essentially | |
202 only needs to express each point in terms of the Barycentric coordinates | |
8480 | 203 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
|
204 @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
|
205 @code{tsearchn}. @code{tsearch} is optimized for 2-dimensions and the |
6823 | 206 Barycentric coordinates are not explicitly formed. |
207 | |
208 @DOCSTRING(tsearch) | |
209 | |
210 @DOCSTRING(tsearchn) | |
211 | |
212 An example of the use of @code{tsearch} can be seen with the simple | |
213 triangulation | |
214 | |
215 @example | |
216 @group | |
217 @var{x} = [-1; -1; 1; 1]; | |
218 @var{y} = [-1; 1; -1; 1]; | |
219 @var{tri} = [1, 2, 3; 2, 3, 1]; | |
220 @end group | |
221 @end example | |
222 | |
223 @noindent | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
224 consisting of two triangles defined by @var{tri}. We can then identify |
6823 | 225 which triangle a point falls in like |
226 | |
227 @example | |
228 @group | |
229 tsearch (@var{x}, @var{y}, @var{tri}, -0.5, -0.5) | |
230 @result{} 1 | |
231 tsearch (@var{x}, @var{y}, @var{tri}, 0.5, 0.5) | |
232 @result{} 2 | |
233 @end group | |
234 @end example | |
235 | |
236 @noindent | |
237 and we can confirm that a point doesn't lie within one of the triangles like | |
238 | |
239 @example | |
240 @group | |
241 tsearch (@var{x}, @var{y}, @var{tri}, 2, 2) | |
242 @result{} NaN | |
243 @end group | |
244 @end example | |
245 | |
246 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
|
247 tessellation to the desired point. The desired point does not |
6823 | 248 necessarily have to be in the tessellation, and even if it the returned |
6832 | 249 point of the tessellation does not have to be one of the vertexes of the |
6823 | 250 N-simplex within which the desired point is found. |
251 | |
252 @DOCSTRING(dsearch) | |
253 | |
254 @DOCSTRING(dsearchn) | |
255 | |
256 An example of the use of @code{dsearch}, using the above values of | |
257 @var{x}, @var{y} and @var{tri} is | |
258 | |
259 @example | |
260 @group | |
261 dsearch (@var{x}, @var{y}, @var{tri}, -2, -2) | |
262 @result{} 1 | |
263 @end group | |
264 @end example | |
265 | |
266 If you wish the points that are outside the tessellation to be flagged, | |
267 then @code{dsearchn} can be used as | |
268 | |
269 @example | |
270 @group | |
271 dsearchn ([@var{x}, @var{y}], @var{tri}, [-2, -2], NaN) | |
272 @result{} NaN | |
273 dsearchn ([@var{x}, @var{y}], @var{tri}, [-0.5, -0.5], NaN) | |
274 @result{} 1 | |
275 @end group | |
276 @end example | |
277 | |
278 @noindent | |
279 where the point outside the tessellation are then flagged with @code{NaN}. | |
280 | |
281 @node Voronoi Diagrams | |
282 @section Voronoi Diagrams | |
283 | |
284 A Voronoi diagram or Voronoi tessellation of a set of points @var{s} in | |
285 an N-dimensional space, is the tessellation of the N-dimensional space | |
286 such that all points in @code{@var{v}(@var{p})}, a partitions of the | |
287 tessellation where @var{p} is a member of @var{s}, are closer to @var{p} | |
288 than any other point in @var{s}. The Voronoi diagram is related to the | |
6832 | 289 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
|
290 Voronoi tessellation are the centers of the circum-circles of the |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9906
diff
changeset
|
291 simplices of the Delaunay tessellation. |
6823 | 292 |
293 @DOCSTRING(voronoi) | |
294 | |
295 @DOCSTRING(voronoin) | |
296 | |
6832 | 297 An example of the use of @code{voronoi} is |
298 | |
299 @example | |
300 @group | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
301 rand ("state",9); |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
302 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
|
303 y = rand (10,1); |
6832 | 304 tri = delaunay (x, y); |
305 [vx, vy] = voronoi (x, y, tri); | |
306 triplot (tri, x, y, "b"); | |
307 hold on; | |
308 plot (vx, vy, "r"); | |
309 @end group | |
310 @end example | |
311 | |
312 @ifnotinfo | |
313 @noindent | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
314 The result of which can be seen in @ref{fig:voronoi}. Note that the |
6832 | 315 circum-circle of one of the triangles has been added to this figure, to |
316 make the relationship between the Delaunay tessellation and the Voronoi | |
317 diagram clearer. | |
318 | |
319 @float Figure,fig:voronoi | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
320 @center @image{voronoi,4in} |
6832 | 321 @caption{Delaunay triangulation and Voronoi diagram of a random set of points} |
322 @end float | |
323 @end ifnotinfo | |
324 | |
6847 | 325 Additional information about the size of the facets of a Voronoi |
326 diagram, and which points of a set of points is in a polygon can be had | |
327 with the @code{polyarea} and @code{inpolygon} functions respectively. | |
6832 | 328 |
329 @DOCSTRING(polyarea) | |
330 | |
331 An example of the use of @code{polyarea} might be | |
332 | |
333 @example | |
334 @group | |
335 rand ("state", 2); | |
336 x = rand (10, 1); | |
337 y = rand (10, 1); | |
338 [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
|
339 af = zeros (size (f)); |
6832 | 340 for i = 1 : length (f) |
341 af(i) = polyarea (c (f @{i, :@}, 1), c (f @{i, :@}, 2)); | |
342 endfor | |
343 @end group | |
344 @end example | |
345 | |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
346 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
|
347 area. A simplified version of @code{polyarea} for rectangles is |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
348 available with @code{rectint} |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
349 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
350 @DOCSTRING(rectint) |
6832 | 351 |
6847 | 352 @DOCSTRING(inpolygon) |
353 | |
354 An example of the use of @code{inpolygon} might be | |
355 | |
356 @example | |
357 @group | |
358 randn ("state", 2); | |
359 x = randn (100, 1); | |
360 y = randn (100, 1); | |
361 vx = cos (pi * [-1 : 0.1: 1]); | |
362 vy = sin (pi * [-1 : 0.1 : 1]); | |
363 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
|
364 plot (vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo"); |
6847 | 365 axis ([-2, 2, -2, 2]); |
366 @end group | |
367 @end example | |
368 | |
369 @ifnotinfo | |
370 @noindent | |
371 The result of which can be seen in @ref{fig:inpolygon}. | |
372 | |
373 @float Figure,fig:inpolygon | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
374 @center @image{inpolygon,4in} |
6847 | 375 @caption{Demonstration of the @code{inpolygon} function to determine the |
376 points inside a polygon} | |
377 @end float | |
378 @end ifnotinfo | |
379 | |
6823 | 380 @node Convex Hull |
381 @section Convex Hull | |
382 | |
7001 | 383 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
|
384 containing all of the points. Octave has the functions @code{convhull} |
7007 | 385 and @code{convhulln} to calculate the convex hull of 2-dimensional and |
6832 | 386 N-dimensional sets of points. |
387 | |
6823 | 388 @DOCSTRING(convhull) |
389 | |
390 @DOCSTRING(convhulln) | |
391 | |
6832 | 392 An example of the use of @code{convhull} is |
6823 | 393 |
6832 | 394 @example |
395 @group | |
396 x = -3:0.05:3; | |
397 y = abs (sin (x)); | |
398 k = convhull (x, y); | |
399 plot (x(k), y(k), "r-", x, y, "b+"); | |
400 axis ([-3.05, 3.05, -0.05, 1.05]); | |
401 @end group | |
402 @end example | |
6823 | 403 |
6832 | 404 @ifnotinfo |
405 @noindent | |
406 The output of the above can be seen in @ref{fig:convhull}. | |
6823 | 407 |
6832 | 408 @float Figure,fig:convhull |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
409 @center @image{convhull,4in} |
6832 | 410 @caption{The convex hull of a simple set of points} |
411 @end float | |
412 @end ifnotinfo | |
6823 | 413 |
414 @node Interpolation on Scattered Data | |
415 @section Interpolation on Scattered Data | |
416 | |
6832 | 417 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
|
418 interpolate from scattered data to an arbitrary set of points. To do |
6832 | 419 this the N-simplex of the known set of points is calculated with |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
420 @code{delaunay}, @code{delaunay3} or @code{delaunayn}. Then the |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9906
diff
changeset
|
421 simplices in to which the desired points are found are |
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9906
diff
changeset
|
422 identified. Finally the vertices of the simplices are used to |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
423 interpolate to the desired points. The functions that perform this |
6832 | 424 interpolation are @code{griddata}, @code{griddata3} and |
425 @code{griddatan}. | |
426 | |
6823 | 427 @DOCSTRING(griddata) |
428 | |
429 @DOCSTRING(griddata3) | |
430 | |
431 @DOCSTRING(griddatan) | |
6832 | 432 |
433 An example of the use of the @code{griddata} function is | |
434 | |
435 @example | |
436 @group | |
14856
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
437 rand ("state", 1); |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
438 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
|
439 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
|
440 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
|
441 [xx,yy] = meshgrid (linspace (-1,1,32)); |
c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
Rik <octave@nomad.inbox5.com>
parents:
14541
diff
changeset
|
442 griddata (x,y,z,xx,yy); |
6832 | 443 @end group |
444 @end example | |
445 | |
446 @noindent | |
447 that interpolates from a random scattering of points, to a uniform | |
448 grid. | |
449 @ifnotinfo | |
450 The output of the above can be seen in @ref{fig:griddata}. | |
451 | |
452 @float Figure,fig:griddata | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
453 @center @image{griddata,4in} |
6832 | 454 @caption{Interpolation from a scattered data to a regular grid} |
455 @end float | |
456 @end ifnotinfo |