# Synopsis

int mth_PointsInPlane(long option, MTH_3DPNT (*pts), int n, double toler, double *normal, double *d)

# Purpose

Compute least squares plane and check coplanarity of points.

# Description

Given n points, this routine computes the least squares plane fitted through these points. It then checks to see if the points are contained within this plane (to a tolerance).

# Input

## option

### MTH_NORMAL

Return the normal to the least squares plane even if the points are not planar.

## pts

The points (3 coordinates per point).

## n

Number of points in the pts array.

## toler

Zero tolerance for checking if a point lies in a plane.

# Output

## normal

The normal vector (3 coordinates) to the computed plane (returned only if the points are coplanar).

## d

The fourth coefficient of the plane equation: .br normal[0]*x + normal[1]*y + normal[2]*z - d = 0.

# Return

          -2 : line or point in xy-plane (points do not define a
               plane).
          -1 : line or point not in xy-plane (do not define a plane).
           0 : points do not lie in a unique plane.
           1 : points lie in a unique plane (not the xy-plane).
           2 : points lie in the xy-plane.
          .fi