Mercurial > hg > octave-lyh
annotate doc/interpreter/geometry.txi @ 10284:c3df189b1b15
more coding tips
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Tue, 09 Feb 2010 11:43:03 +0100 |
parents | 8d20fb66a0dc |
children | 3140cb7a05a1 |
rev | line source |
---|---|
8920 | 1 @c Copyright (C) 2007, 2008, 2009 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., |
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 "The Quickhull algorithm for convex hulls," ACM Trans. on Mathematical |
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]); | |
75 plot(X, Y, "b", x, y, "r*"); | |
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:: |
6823 | 91 * Identifying points in Triangulation:: |
92 @end menu | |
93 | |
6832 | 94 @node Plotting the Triangulation |
95 @subsection Plotting the Triangulation | |
96 | |
97 Octave has the functions @code{triplot} and @code{trimesh} to plot the | |
98 Delaunay triangulation of a 2-dimensional set of points. | |
99 | |
100 @DOCSTRING(triplot) | |
101 | |
102 @DOCSTRING(trimesh) | |
103 | |
104 The difference between @code{triplot} and @code{trimesh} is that the | |
105 former only plots the 2-dimensional triangulation itself, whereas the | |
106 second plots the value of some function @code{f (@var{x}, @var{y})}. | |
107 An example of the use of the @code{triplot} function is | |
108 | |
109 @example | |
110 @group | |
111 rand ("state", 2) | |
112 x = rand (20, 1); | |
113 y = rand (20, 1); | |
114 tri = delaunay (x, y); | |
115 triplot (tri, x, y); | |
116 @end group | |
117 @end example | |
118 | |
119 that plot the Delaunay triangulation of a set of random points in | |
120 2-dimensions. | |
121 @ifnotinfo | |
122 The output of the above can be seen in @ref{fig:triplot}. | |
123 | |
124 @float Figure,fig:triplot | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
125 @center @image{triplot,4in} |
6832 | 126 @caption{Delaunay triangulation of a random set of points} |
127 @end float | |
128 @end ifnotinfo | |
129 | |
6823 | 130 @node Identifying points in Triangulation |
131 @subsection Identifying points in Triangulation | |
132 | |
133 It is often necessary to identify whether a particular point in the | |
7007 | 134 N-dimensional space is within the Delaunay tessellation of a set of |
8480 | 135 points in this N-dimensional space, and if so which N-simplex contains |
7007 | 136 the point and which point in the tessellation is closest to the desired |
6823 | 137 point. The functions @code{tsearch} and @code{dsearch} perform this |
138 function in a triangulation, and @code{tsearchn} and @code{dsearchn} in | |
7007 | 139 an N-dimensional tessellation. |
6823 | 140 |
141 To identify whether a particular point represented by a vector @var{p} | |
8480 | 142 falls within one of the simplices of an N-simplex, we can write the |
6823 | 143 Cartesian coordinates of the point in a parametric form with respect to |
8480 | 144 the N-simplex. This parametric form is called the Barycentric |
145 Coordinates of the point. If the points defining the N-simplex are given | |
6823 | 146 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
|
147 coordinates defining the point @var{p} are given by |
6823 | 148 |
149 @example | |
150 @var{p} = sum (@var{beta}(1:@var{N}+1) * @var{t}(1:@var{N}+1),:) | |
151 @end example | |
152 | |
153 @noindent | |
154 where there are @code{@var{N} + 1} values @code{@var{beta}(@var{i})} | |
155 that together as a vector represent the Barycentric coordinates of the | |
156 point @var{p}. To ensure a unique solution for the values of | |
157 @code{@var{beta}(@var{i})} an additional criteria of | |
158 | |
159 @example | |
160 sum (@var{beta}(1:@var{N}+1)) == 1 | |
161 @end example | |
162 | |
163 @noindent | |
164 is imposed, and we can therefore write the above as | |
165 | |
166 @example | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
167 @group |
6823 | 168 @var{p} - @var{t}(end, :) = @var{beta}(1:end-1) * (@var{t}(1:end-1, :) |
169 - 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
|
170 @end group |
6823 | 171 @end example |
172 | |
173 @noindent | |
174 Solving for @var{beta} we can then write | |
175 | |
176 @example | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
177 @group |
6823 | 178 @var{beta}(1:end-1) = (@var{p} - @var{t}(end, :)) / (@var{t}(1:end-1, :) |
179 - ones(@var{N}, 1) * @var{t}(end, :)) | |
180 @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
|
181 @end group |
6823 | 182 @end example |
183 | |
184 @noindent | |
185 which gives the formula for the conversion of the Cartesian coordinates | |
186 of the point @var{p} to the Barycentric coordinates @var{beta}. An | |
187 important property of the Barycentric coordinates is that for all points | |
8480 | 188 in the N-simplex |
6823 | 189 |
190 @example | |
191 0 <= @var{beta}(@var{i}) <= 1 | |
192 @end example | |
193 | |
194 @noindent | |
195 Therefore, the test in @code{tsearch} and @code{tsearchn} essentially | |
196 only needs to express each point in terms of the Barycentric coordinates | |
8480 | 197 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
|
198 @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
|
199 @code{tsearchn}. @code{tsearch} is optimized for 2-dimensions and the |
6823 | 200 Barycentric coordinates are not explicitly formed. |
201 | |
202 @DOCSTRING(tsearch) | |
203 | |
204 @DOCSTRING(tsearchn) | |
205 | |
206 An example of the use of @code{tsearch} can be seen with the simple | |
207 triangulation | |
208 | |
209 @example | |
210 @group | |
211 @var{x} = [-1; -1; 1; 1]; | |
212 @var{y} = [-1; 1; -1; 1]; | |
213 @var{tri} = [1, 2, 3; 2, 3, 1]; | |
214 @end group | |
215 @end example | |
216 | |
217 @noindent | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
218 consisting of two triangles defined by @var{tri}. We can then identify |
6823 | 219 which triangle a point falls in like |
220 | |
221 @example | |
222 @group | |
223 tsearch (@var{x}, @var{y}, @var{tri}, -0.5, -0.5) | |
224 @result{} 1 | |
225 tsearch (@var{x}, @var{y}, @var{tri}, 0.5, 0.5) | |
226 @result{} 2 | |
227 @end group | |
228 @end example | |
229 | |
230 @noindent | |
231 and we can confirm that a point doesn't lie within one of the triangles like | |
232 | |
233 @example | |
234 @group | |
235 tsearch (@var{x}, @var{y}, @var{tri}, 2, 2) | |
236 @result{} NaN | |
237 @end group | |
238 @end example | |
239 | |
240 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
|
241 tessellation to the desired point. The desired point does not |
6823 | 242 necessarily have to be in the tessellation, and even if it the returned |
6832 | 243 point of the tessellation does not have to be one of the vertexes of the |
6823 | 244 N-simplex within which the desired point is found. |
245 | |
246 @DOCSTRING(dsearch) | |
247 | |
248 @DOCSTRING(dsearchn) | |
249 | |
250 An example of the use of @code{dsearch}, using the above values of | |
251 @var{x}, @var{y} and @var{tri} is | |
252 | |
253 @example | |
254 @group | |
255 dsearch (@var{x}, @var{y}, @var{tri}, -2, -2) | |
256 @result{} 1 | |
257 @end group | |
258 @end example | |
259 | |
260 If you wish the points that are outside the tessellation to be flagged, | |
261 then @code{dsearchn} can be used as | |
262 | |
263 @example | |
264 @group | |
265 dsearchn ([@var{x}, @var{y}], @var{tri}, [-2, -2], NaN) | |
266 @result{} NaN | |
267 dsearchn ([@var{x}, @var{y}], @var{tri}, [-0.5, -0.5], NaN) | |
268 @result{} 1 | |
269 @end group | |
270 @end example | |
271 | |
272 @noindent | |
273 where the point outside the tessellation are then flagged with @code{NaN}. | |
274 | |
275 @node Voronoi Diagrams | |
276 @section Voronoi Diagrams | |
277 | |
278 A Voronoi diagram or Voronoi tessellation of a set of points @var{s} in | |
279 an N-dimensional space, is the tessellation of the N-dimensional space | |
280 such that all points in @code{@var{v}(@var{p})}, a partitions of the | |
281 tessellation where @var{p} is a member of @var{s}, are closer to @var{p} | |
282 than any other point in @var{s}. The Voronoi diagram is related to the | |
6832 | 283 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
|
284 Voronoi tessellation are the centers of the circum-circles of the |
6832 | 285 simplicies of the Delaunay tessellation. |
6823 | 286 |
287 @DOCSTRING(voronoi) | |
288 | |
289 @DOCSTRING(voronoin) | |
290 | |
6832 | 291 An example of the use of @code{voronoi} is |
292 | |
293 @example | |
294 @group | |
295 rand("state",9); | |
296 x = rand(10,1); | |
297 y = rand(10,1); | |
298 tri = delaunay (x, y); | |
299 [vx, vy] = voronoi (x, y, tri); | |
300 triplot (tri, x, y, "b"); | |
301 hold on; | |
302 plot (vx, vy, "r"); | |
303 @end group | |
304 @end example | |
305 | |
306 @ifnotinfo | |
307 @noindent | |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
308 The result of which can be seen in @ref{fig:voronoi}. Note that the |
6832 | 309 circum-circle of one of the triangles has been added to this figure, to |
310 make the relationship between the Delaunay tessellation and the Voronoi | |
311 diagram clearer. | |
312 | |
313 @float Figure,fig:voronoi | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
314 @center @image{voronoi,4in} |
6832 | 315 @caption{Delaunay triangulation and Voronoi diagram of a random set of points} |
316 @end float | |
317 @end ifnotinfo | |
318 | |
6847 | 319 Additional information about the size of the facets of a Voronoi |
320 diagram, and which points of a set of points is in a polygon can be had | |
321 with the @code{polyarea} and @code{inpolygon} functions respectively. | |
6832 | 322 |
323 @DOCSTRING(polyarea) | |
324 | |
325 An example of the use of @code{polyarea} might be | |
326 | |
327 @example | |
328 @group | |
329 rand ("state", 2); | |
330 x = rand (10, 1); | |
331 y = rand (10, 1); | |
332 [c, f] = voronoin ([x, y]); | |
333 af = zeros (size(f)); | |
334 for i = 1 : length (f) | |
335 af(i) = polyarea (c (f @{i, :@}, 1), c (f @{i, :@}, 2)); | |
336 endfor | |
337 @end group | |
338 @end example | |
339 | |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
340 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
|
341 area. A simplified version of @code{polyarea} for rectangles is |
7984
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
342 available with @code{rectint} |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
343 |
bbaa5d7d0143
Some documentation updates
David Bateman <dbateman@free.fr>
parents:
7018
diff
changeset
|
344 @DOCSTRING(rectint) |
6832 | 345 |
6847 | 346 @DOCSTRING(inpolygon) |
347 | |
348 An example of the use of @code{inpolygon} might be | |
349 | |
350 @example | |
351 @group | |
352 randn ("state", 2); | |
353 x = randn (100, 1); | |
354 y = randn (100, 1); | |
355 vx = cos (pi * [-1 : 0.1: 1]); | |
356 vy = sin (pi * [-1 : 0.1 : 1]); | |
357 in = inpolygon (x, y, vx, vy); | |
358 plot(vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo"); | |
359 axis ([-2, 2, -2, 2]); | |
360 @end group | |
361 @end example | |
362 | |
363 @ifnotinfo | |
364 @noindent | |
365 The result of which can be seen in @ref{fig:inpolygon}. | |
366 | |
367 @float Figure,fig:inpolygon | |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
368 @center @image{inpolygon,4in} |
6847 | 369 @caption{Demonstration of the @code{inpolygon} function to determine the |
370 points inside a polygon} | |
371 @end float | |
372 @end ifnotinfo | |
373 | |
6823 | 374 @node Convex Hull |
375 @section Convex Hull | |
376 | |
7001 | 377 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
|
378 containing all of the points. Octave has the functions @code{convhull} |
7007 | 379 and @code{convhulln} to calculate the convex hull of 2-dimensional and |
6832 | 380 N-dimensional sets of points. |
381 | |
6823 | 382 @DOCSTRING(convhull) |
383 | |
384 @DOCSTRING(convhulln) | |
385 | |
6832 | 386 An example of the use of @code{convhull} is |
6823 | 387 |
6832 | 388 @example |
389 @group | |
390 x = -3:0.05:3; | |
391 y = abs (sin (x)); | |
392 k = convhull (x, y); | |
393 plot (x(k), y(k), "r-", x, y, "b+"); | |
394 axis ([-3.05, 3.05, -0.05, 1.05]); | |
395 @end group | |
396 @end example | |
6823 | 397 |
6832 | 398 @ifnotinfo |
399 @noindent | |
400 The output of the above can be seen in @ref{fig:convhull}. | |
6823 | 401 |
6832 | 402 @float Figure,fig:convhull |
9088
77e71f3da3d6
Fix documentation image printing under new development code
Rik <rdrider0-list@yahoo.com>
parents:
9070
diff
changeset
|
403 @center @image{convhull,4in} |
6832 | 404 @caption{The convex hull of a simple set of points} |
405 @end float | |
406 @end ifnotinfo | |
6823 | 407 |
408 @node Interpolation on Scattered Data | |
409 @section Interpolation on Scattered Data | |
410 | |
6832 | 411 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
|
412 interpolate from scattered data to an arbitrary set of points. To do |
6832 | 413 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
|
414 @code{delaunay}, @code{delaunay3} or @code{delaunayn}. Then the |
6832 | 415 simplicies in to which the desired points are found are |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
416 identified. Finally the vertices of the simplicies are used to |
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
417 interpolate to the desired points. The functions that perform this |
6832 | 418 interpolation are @code{griddata}, @code{griddata3} and |
419 @code{griddatan}. | |
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 | |
431 rand("state",1); | |
432 x=2*rand(1000,1)-1; | |
433 y=2*rand(size(x))-1; | |
434 z=sin(2*(x.^2+y.^2)); | |
435 [xx,yy]=meshgrid(linspace(-1,1,32)); | |
436 griddata(x,y,z,xx,yy); | |
437 @end group | |
438 @end example | |
439 | |
440 @noindent | |
441 that interpolates from a random scattering of points, to a uniform | |
442 grid. | |
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 |