Name
bary — compute weighted sums of points
DESCRIPTION
bary computes weighted sums of a set of sites in Euclidean 3-space, writing them on the standard output. The site weights are read from file if it is specified; otherwise, bary reads from the standard input. A line of input must be either (1) entirely white space, (2) white space followed by a comment (begun with the '#' character), or (3) white-space-separated weights, one per site.
By default,
bary
uses the three sites (1, 0, 0), (0, 1, 0), and (0, 0, 1).
One or more occurrences of the
-s
option cause
bary
to replace
the default sites with all the sites
(x, y, z)
so specified.
The
-n
option causes
bary
to normalize each tuple of weights to sum to one.
This has the effect of computing
barycentric combinations of the sites.
If any line of weights in the input stream
contains more fields than the number of sites,
bary
will, by default,
ignore the excess fields.
The
-t
option causes
bary
to copy all such trailing fields verbatim onto the tail of
the corresponding line of output.
EXAMPLE
The command
bary -tn -s '0 0 0' -s '1 0 0' -s '0.5 0.866 0' <<EOF
#------------------------------
# x y z aux. data
#------------------------------
1.0 2.5 3.6 58 alpha
0.0 1.0 2.0 37 bravo
13.0 9.2 6.3 69 charlie delta
EOF
maps the triples to points in an equilateral triangle in the xy-plane, producing the following output:
0.605634 0.439099 0 58 alpha
0.666667 0.577333 0 37 bravo
0.433333 0.191432 0 69 charlie delta