Description
T%ARE-POINTS-COLLINEAR is an AutoLisp Sub-Function, by CadToolChest, which functions within AutoCAD 2002, and later (possibly earlier). It determines if 3 or more 2D or 3D points are collinear, and return a 3 element list with the 1st element being T if all points are collinear, and nil otherwise. The 2nd element is a list of all points that are collinear (always includes the first 2 points of the argument to the function). The 3rd element is a list of all points that are not collinear (or nil otherwise if all are collinear).
Note: If an element of the list is not a 2D or 3D point, the test will consider that element as non-collinear.
This function requires an additional CadToolChest file which must be downloaded separately (see left margin).
Syntax:
(T%ARE-POINTS-COLLINEAR POINT-LIST)
Where:
POINT-LIST=A list of 3 or more 2D or 3D points to be compared. The first two define the line to which the remaining points will be compared.
Example 1:
(T%ARE-POINTS-COLLINEAR (list (list 0.0 0.0 0.0) (list 10.0 0.0 0.0) (list 5.0 0.0 0.0)))
Returns: (T ((0.0 0.0 0.0) (10.0 0.0 0.0) (5.0 0.0 0.0)) nil)
Example 2:
(T%ARE-POINTS-COLLINEAR (list (list 0.0 0.0 0.0) (list 10.0 0.0 0.0) (list 15.0 0.0 0.0) (list 5.0 0.0 0.0)))
Returns: (T ((0.0 0.0 0.0) (10.0 0.0 0.0) (15.0 0.0 0.0) (5.0 0.0 0.0)) nil)
Example 3:
(T%ARE-POINTS-COLLINEAR (list (list 0.0 0.0 0.0) (list 10.0 0.0 0.0) (list 15.0 0.0 1.0)))
Returns: (nil ((0.0 0.0 0.0) (10.0 0.0 0.0)) ((15.0 0.0 1.0)))
Example 4:
(T%ARE-POINTS-COLLINEAR (list (list 0.0 0.0 0.0) (list 10.0 0.0 0.0) "abc")
Returns: (nil ((0.0 0.0 0.0) (10.0 0.0 0.0)) ("abc"))
Note: Always check the CAR of the returned list to determine if T or Nil a list is always returned making the return True. For example:
(if (car T%Are-Points-collinear Point-List))
(prompt "\nTrue")
(prompt "\nNIL")
) ;_ if