Woolz Image Processing  Version 1.7.5
Name
WlzFitPlane - Calculates the best (least squares) plane through the given input vertices.
Synopsis
WlzFitPlane [-o <output file>] [-h]
[-a] [-A <alg>]  [-T] [-u<x>,<y>,<z>] [<input file>]

Options
 -a Output is an affine transform. -A Force the algorithm selection, valid algorithms are: SVD - Singular Value Decomposition based least squares (the default). -h Help - print help message -o Output object file name. -s Output is 3D view struct (default). -t Output is a text description of the plane. -T Use test data, probably only useful for debugging. -u Up vector, the default is (0, 0, 0) which implies that the up vector is not explicitly set. -w Input is a Woolz object rather than ascii vertices.
Description
WlzFitPlane computes a least squares best fit plane through the given input vertices or object. Text output is of the form:
  <nx> <ny> <nz> <fx> <fy> <fz> <pitch> <yaw>

where these are the normal components, centroid location in the plane and the Euler angles (in degrees). The input vertices are read from an ascii file with the format:
  <vx> <vy> <vz>

The input data are read from stdin and the output object is written to stdout unless the filenames are given.
Examples
cat tst.num
181 62 39
105 192 97
281 185 282
342 81 235
118 139 54
221 146 173
312 147 274
225 69 94
190 148 142
141 208 154
WlzFitPlane tst.num -t
-0.593865 -0.592398 0.544417 211.6 137.7 154.4 57.0152 224.929

Note that although the output plane is a least squares solution is is not unique (eg pitch=123.0, yaw=45.0 are also valid solutions).
File
WlzFitPlane.c