Synopsis
PDX_BOOL mth_PointsDefineLine(double pts[], long n, int nc, double length_tol, double error_tol, long *start, long *end)
Purpose
Check if set of points lie on a straight line of minimum length
Description
This routine checks if a set of points lies on a straight line of minimum length. The points may be 2D or 3D. It finds the two points farthest away from one another, and then checks if all other points are within tolerance of the line defined by these two points. It makes no assumptions about the geometric ordering of the points.
Input
pts
The set of points. pts is accessed as a 1D array. The points may have either 2 or 3 coordinates (see nc). The first coordinate of the second point is at pts[nc].
n
The number of points in pts.
nc
The number of coordinates per point.
length_tol
The line segment must have length greater than this tolerance, otherwise PDX_FALSE is returned.
error_tol
All points must be within this tolerance of the line defined by the two farthest points, otherwise PDX_FALSE is returned.
Output
start
Index of the first point defining the line.
end
Index of the second point defining the line.
Return
PDX_TRUE if points form a line; otherwise, PDX_FALSE