NAME
voronoi_unit -- compute voronoi tesselation
PROTOTYPE
unitptr voronoi_unit( int iOperands, int iNum, char *pcOptions, unitptr uHost)
ARGUMENTS
- int iOperands
- nr of operand units
- int iNum
- nr of points
- char *pcOptions
- options (see below)
- unitptr uHost
- host unit
RETURN VALUE:
A pointer to the created unit or NULL in the case of an error.
INTERFACE OF CREATED UNIT:
- X_in[iDim]:
- (input field 0) input for the center points.
If iNum!=0, the input of the centers for abs(.iNum)
points is expected. In this case, X_in[] expects
abs(iNum) pairs (x,y) (or, optionally,
triples (w,x,y)), specifying
the 2D-coordinates (and optionally, an additional
weight factor r) of the abs(iNum) center points
for which the Voronoi tesselation is to be computed.
The optional use of the weight factors r (see below)
is chosen by specifying the option %W in pcOptions.
In this case, iDim=3*iNum, otherwise iDim=2*iNum.
If iNum=0, the input is assumed to be given
sequentially, i.e. one pair (x,y) or triple (r,x,y)
per exec_unit-call. Thus, in this case, iDim=3
or iDim=2, depending on whether option %W is
chosen or not in pcOptions. The computation of
the Voronoi tesselation is in this case carried out
when the number of input points reaches or exceeds
the current value at CTL_in[0]. The stored points
are deleted and a new cycle may begin with the
next exec_unit-call.
- CTL_in[1]:
- (control field) A value of 0 makes the unit return
without any operation. For other values, see above.
- X_out[2]:
- (output field 0): index of current cell center and
index of current neighbor.
- Y_out[2]:
- (output field 1) location of Voronoi center 1
(see below)
- Z_out[2]:
- (output field 2) location of Voronoi center 2
(see below)
- out_3[2]:
- (output field 3) clockwise Voronoi edge point
- out_4[2]:
- (output field 4) counterclockwise Voronoi edge point.
Usually, these will be the end points of the edge,
unless out_5[2]!=0, in which case one of the two
end points is at infinity and a closer, `clipped''
point is given instead.
- out_5[2]:
- Flags indicating that current edge extends to infinity
on its clockwise or counterclockwise or on both sides.
In this case, the returned point on the infinite side(s)
is clipped.
EXECUTION OF CREATED UNIT:
Computes Voronoi tesselation for a given number of points in
the plane. When the computation has been done, the unit iterates
its iOperands over all edges of the Voronoi cells. At each iteration,
the current edge is identified by the coordinates and indices of the
two Voronoi cells that share the edge. The first Voronoi center 1
will be the slow, the second Voronoi center 2 the fast index.
Additionally, two points on
the edge (usually the end points) are given. For edges that extend
to infinity, the infinite end(s) will be approximated by a clipped
point. This is indicated by a nonzero value in the corresponding
component of out_4[2] (element 0 corresponds to the clockwise,
element 1 to the counterclockwise end of the edge).
OPTIONS:
Currently, the following options are recognized
in pcOptions:
- %D:
- traverse of each voronoi cell center all its neigbhors
in counterclockwise order (this requires to visit
each center pair twice and is thus slower)
- %W:
- compute a weighted Voronoi tesselation. Input must
then be 3 values per center (weight,x,y).
EXAMPLES:
STATUS:
alpha
FILE
/local/homes/rhaschke/nst7/man/../o.linx86//../nstsrc/nst_voro.c