CadToolChest FREE

for AutoCAD    

 

 

<Back





Download:

T%Are-
Points-
Collinear




Requires:

T%Is-It-
A-Point

T%ARE-POINTS-COLLINEAR.LSP
Version: 2006-10-14
AutoCAD 2002 through 2007




Are-Points-Collinear.gif

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

<Back



This program is distributed, by CadToolChest, as Freeware without guarantee or warranty of any type.  You may freely use, modify and/or distribute this program for personal or commercial use, but you may not sell or charge for it or any portion of it.  If bundled with a product that is sold, you must make this program available for free.  As customary, acknowledge the original author's contribution if you build upon or distribute this work.

The author of CadToolChest retains all copyrights other than described above.



  C O N T A C T       C A D T O O L C H E S T  
Feedback Form
 (e-Mail address not required)
ani-email-at.gif

Visitors since 2006/10/06

Free Hit Counter
USA-ani-Flag.gif

   USA

Visitors Web Counter