SCULIB_FIT_PLANE

fits a plane to some x, y, z data

Description:

This routine does a least squares fit of data to a plane. The plane is described by an equation of form:-
z = MX x + MY y + C (44)

Invocation

CALL SCULIB_FIT_PLANE (N, X, Y, Z, QUALITY, MX, MY, C, STATUS)

Arguments

N = INTEGER (Given)
the number of data points
X (N) = REAL (Given)
the x coords of the measured points
Y (N) = REAL (Given)
the y coords of the measured points
Z (N) = REAL (Given)
the measured values
QUALITY (N) = INTEGER (Given)
the quality on the data
MX = REAL (Returned)
the slope of the fitted plane in the x-axis
MY = REAL (Returned)
the slope of the fitted plane in the y-axis
C = REAL (Returned)
the constant of the fitted plane
STATUS = INTEGER (Given and returned)
global status

Method

If status is good on entry the routine will loop through the input data calculating the sums required and the number of valid data points (i.e. those with good quality flags).

If there are less than 3 valid data then an error message will be output and bad status returned else the plane coefficients will be calculated from the following formulae:-

MX = y2(nvxzxz) (y)2xznvxyyz +y(xyz +xyz) 2xyxynv(xy)2 (x)2y2 +x2(nvy2 + (y)2) (45)
MY = nvyzyz + MX(xynvxy) nvy2 y2 (46)
C = zMXxMYy nv (47)

where nv is the number of valid data points. If the denominator of the expression for MX is 0 then an error message will be output and bad status returned.

end if

Copyright

Copyright ©1995,1996,1997,1998,1999 Particle Physics and Astronomy Research Council. All Rights Reserved.