1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Voronoi Diagrams (GNU Octave (version 6.2.0))</title>
<meta name="description" content="Voronoi Diagrams (GNU Octave (version 6.2.0))">
<meta name="keywords" content="Voronoi Diagrams (GNU Octave (version 6.2.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Geometry.html" rel="up" title="Geometry">
<link href="Convex-Hull.html" rel="next" title="Convex Hull">
<link href="Identifying-Points-in-Triangulation.html" rel="prev" title="Identifying Points in Triangulation">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<span id="Voronoi-Diagrams"></span><div class="header">
<p>
Next: <a href="Convex-Hull.html" accesskey="n" rel="next">Convex Hull</a>, Previous: <a href="Delaunay-Triangulation.html" accesskey="p" rel="prev">Delaunay Triangulation</a>, Up: <a href="Geometry.html" accesskey="u" rel="up">Geometry</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<span id="Voronoi-Diagrams-1"></span><h3 class="section">30.2 Voronoi Diagrams</h3>
<p>A Voronoi diagram or Voronoi tessellation of a set of points <var>s</var> in
an N-dimensional space, is the tessellation of the N-dimensional space
such that all points in <code><var>v</var>(<var>p</var>)</code>, a partitions of the
tessellation where <var>p</var> is a member of <var>s</var>, are closer to <var>p</var>
than any other point in <var>s</var>. The Voronoi diagram is related to the
Delaunay triangulation of a set of points, in that the vertices of the
Voronoi tessellation are the centers of the circum-circles of the
simplices of the Delaunay tessellation.
</p>
<span id="XREFvoronoi"></span><dl>
<dt id="index-voronoi">: <em></em> <strong>voronoi</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt id="index-voronoi-1">: <em></em> <strong>voronoi</strong> <em>(<var>x</var>, <var>y</var>, <var>options</var>)</em></dt>
<dt id="index-voronoi-2">: <em></em> <strong>voronoi</strong> <em>(…, "linespec")</em></dt>
<dt id="index-voronoi-3">: <em></em> <strong>voronoi</strong> <em>(<var>hax</var>, …)</em></dt>
<dt id="index-voronoi-4">: <em><var>h</var> =</em> <strong>voronoi</strong> <em>(…)</em></dt>
<dt id="index-voronoi-5">: <em>[<var>vx</var>, <var>vy</var>] =</em> <strong>voronoi</strong> <em>(…)</em></dt>
<dd><p>Plot the Voronoi diagram of points <code>(<var>x</var>, <var>y</var>)</code>.
</p>
<p>The Voronoi facets with points at infinity are not drawn.
</p>
<p>The <var>options</var> argument, which must be a string or cell array of strings,
contains options passed to the underlying qhull command.
See the documentation for the Qhull library for details
<a href="http://www.qhull.org/html/qh-quick.htm#options">http://www.qhull.org/html/qh-quick.htm#options</a>.
</p>
<p>If <code>"linespec"</code> is given it is used to set the color and line style of
the plot.
</p>
<p>If an axes graphics handle <var>hax</var> is supplied then the Voronoi diagram is
drawn on the specified axes rather than in a new figure.
</p>
<p>If a single output argument is requested then the Voronoi diagram will be
plotted and a graphics handle <var>h</var> to the plot is returned.
</p>
<p>[<var>vx</var>, <var>vy</var>] = voronoi (…) returns the Voronoi vertices
instead of plotting the diagram.
</p>
<div class="example">
<pre class="example">x = rand (10, 1);
y = rand (size (x));
h = convhull (x, y);
[vx, vy] = voronoi (x, y);
plot (vx, vy, "-b", x, y, "o", x(h), y(h), "-g");
legend ("", "points", "hull");
</pre></div>
<p><strong>See also:</strong> <a href="#XREFvoronoin">voronoin</a>, <a href="Delaunay-Triangulation.html#XREFdelaunay">delaunay</a>, <a href="Convex-Hull.html#XREFconvhull">convhull</a>.
</p></dd></dl>
<span id="XREFvoronoin"></span><dl>
<dt id="index-voronoin">: <em>[<var>C</var>, <var>F</var>] =</em> <strong>voronoin</strong> <em>(<var>pts</var>)</em></dt>
<dt id="index-voronoin-1">: <em>[<var>C</var>, <var>F</var>] =</em> <strong>voronoin</strong> <em>(<var>pts</var>, <var>options</var>)</em></dt>
<dd><p>Compute N-dimensional Voronoi facets.
</p>
<p>The input matrix <var>pts</var> of size [n, dim] contains n points in a space of
dimension dim.
</p>
<p><var>C</var> contains the points of the Voronoi facets. The list <var>F</var>
contains, for each facet, the indices of the Voronoi points.
</p>
<p>An optional second argument, which must be a string or cell array of
strings, contains options passed to the underlying qhull command. See the
documentation for the Qhull library for details
<a href="http://www.qhull.org/html/qh-quick.htm#options">http://www.qhull.org/html/qh-quick.htm#options</a>.
</p>
<p>The default options depend on the dimension of the input:
</p>
<ul>
<li> 2-D and 3-D: <var>options</var> = <code>{"Qbb"}</code>
</li><li> 4-D and higher: <var>options</var> = <code>{"Qbb", "Qx"}</code>
</li></ul>
<p>If <var>options</var> is not present or <code>[]</code> then the default arguments are
used. Otherwise, <var>options</var> replaces the default argument list.
To append user options to the defaults it is necessary to repeat the
default arguments in <var>options</var>. Use a null string to pass no arguments.
</p>
<p><strong>See also:</strong> <a href="#XREFvoronoi">voronoi</a>, <a href="Convex-Hull.html#XREFconvhulln">convhulln</a>, <a href="Delaunay-Triangulation.html#XREFdelaunayn">delaunayn</a>.
</p></dd></dl>
<p>An example of the use of <code>voronoi</code> is
</p>
<div class="example">
<pre class="example">rand ("state",9);
x = rand (10,1);
y = rand (10,1);
tri = delaunay (x, y);
[vx, vy] = voronoi (x, y, tri);
triplot (tri, x, y, "b");
hold on;
plot (vx, vy, "r");
</pre></div>
<p>The result of which can be seen in <a href="#fig_003avoronoi">Figure 30.3</a>. Note that the
circum-circle of one of the triangles has been added to this figure, to
make the relationship between the Delaunay tessellation and the Voronoi
diagram clearer.
</p>
<div class="float"><span id="fig_003avoronoi"></span>
<div align="center"><img src="voronoi.png" alt="voronoi">
</div>
<div class="float-caption"><p><strong>Figure 30.3: </strong>Delaunay triangulation (blue lines) and Voronoi diagram (red lines)
of a random set of points</p></div></div>
<p>Additional information about the size of the facets of a Voronoi
diagram, and which points of a set of points is in a polygon can be had
with the <code>polyarea</code> and <code>inpolygon</code> functions respectively.
</p>
<span id="XREFpolyarea"></span><dl>
<dt id="index-polyarea">: <em></em> <strong>polyarea</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt id="index-polyarea-1">: <em></em> <strong>polyarea</strong> <em>(<var>x</var>, <var>y</var>, <var>dim</var>)</em></dt>
<dd>
<p>Determine area of a polygon by triangle method.
</p>
<p>The variables <var>x</var> and <var>y</var> define the vertex pairs, and must
therefore have the same shape. They can be either vectors or arrays. If
they are arrays then the columns of <var>x</var> and <var>y</var> are treated
separately and an area returned for each.
</p>
<p>If the optional <var>dim</var> argument is given, then <code>polyarea</code> works
along this dimension of the arrays <var>x</var> and <var>y</var>.
</p>
</dd></dl>
<p>An example of the use of <code>polyarea</code> might be
</p>
<div class="example">
<pre class="example">rand ("state", 2);
x = rand (10, 1);
y = rand (10, 1);
[c, f] = voronoin ([x, y]);
af = zeros (size (f));
for i = 1 : length (f)
af(i) = polyarea (c (f {i, :}, 1), c (f {i, :}, 2));
endfor
</pre></div>
<p>Facets of the Voronoi diagram with a vertex at infinity have infinity
area. A simplified version of <code>polyarea</code> for rectangles is
available with <code>rectint</code>
</p>
<span id="XREFrectint"></span><dl>
<dt id="index-rectint">: <em><var>area</var> =</em> <strong>rectint</strong> <em>(<var>a</var>, <var>b</var>)</em></dt>
<dd><p>Compute area or volume of intersection of rectangles or N-D boxes.
</p>
<p>Compute the area of intersection of rectangles in <var>a</var> and rectangles in
<var>b</var>. N-dimensional boxes are supported in which case the volume, or
hypervolume is computed according to the number of dimensions.
</p>
<p>2-dimensional rectangles are defined as <code>[xpos ypos width height]</code>
where xpos and ypos are the position of the bottom left corner. Higher
dimensions are supported where the coordinates for the minimum value of each
dimension follow the length of the box in that dimension, e.g.,
<code>[xpos ypos zpos kpos … width height depth k_length …]</code>.
</p>
<p>Each row of <var>a</var> and <var>b</var> define a rectangle, and if both define
multiple rectangles, then the output, <var>area</var>, is a matrix where the i-th
row corresponds to the i-th row of a and the j-th column corresponds to the
j-th row of b.
</p>
<p><strong>See also:</strong> <a href="#XREFpolyarea">polyarea</a>.
</p></dd></dl>
<span id="XREFinpolygon"></span><dl>
<dt id="index-inpolygon">: <em><var>in</var> =</em> <strong>inpolygon</strong> <em>(<var>x</var>, <var>y</var>, <var>xv</var>, <var>yv</var>)</em></dt>
<dt id="index-inpolygon-1">: <em>[<var>in</var>, <var>on</var>] =</em> <strong>inpolygon</strong> <em>(<var>x</var>, <var>y</var>, <var>xv</var>, <var>yv</var>)</em></dt>
<dd>
<p>For a polygon defined by vertex points <code>(<var>xv</var>, <var>yv</var>)</code>, return
true if the points <code>(<var>x</var>, <var>y</var>)</code> are inside (or on the boundary)
of the polygon; Otherwise, return false.
</p>
<p>The input variables <var>x</var> and <var>y</var>, must have the same dimension.
</p>
<p>The optional output <var>on</var> returns true if the points are exactly on the
polygon edge, and false otherwise.
</p>
<p><strong>See also:</strong> <a href="Delaunay-Triangulation.html#XREFdelaunay">delaunay</a>.
</p></dd></dl>
<p>An example of the use of <code>inpolygon</code> might be
</p>
<div class="example">
<pre class="example">randn ("state", 2);
x = randn (100, 1);
y = randn (100, 1);
vx = cos (pi * [-1 : 0.1: 1]);
vy = sin (pi * [-1 : 0.1 : 1]);
in = inpolygon (x, y, vx, vy);
plot (vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo");
axis ([-2, 2, -2, 2]);
</pre></div>
<p>The result of which can be seen in <a href="#fig_003ainpolygon">Figure 30.4</a>.
</p>
<div class="float"><span id="fig_003ainpolygon"></span>
<div align="center"><img src="inpolygon.png" alt="inpolygon">
</div>
<div class="float-caption"><p><strong>Figure 30.4: </strong>Demonstration of the <code>inpolygon</code> function to determine the
points inside a polygon</p></div></div>
<hr>
<div class="header">
<p>
Next: <a href="Convex-Hull.html" accesskey="n" rel="next">Convex Hull</a>, Previous: <a href="Delaunay-Triangulation.html" accesskey="p" rel="prev">Delaunay Triangulation</a>, Up: <a href="Geometry.html" accesskey="u" rel="up">Geometry</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|