;; | ---------------------------------------------------------------------------- ;; | GE_Collinear? ;; | ---------------------------------------------------------------------------- ;; | Function : Find out if three points are collinear within a given tolerance ;; | Argument : [p1] - First point ;; | [p2] - Second point ;; | [p3] - Third point ;; | [InBetFlag] - In Between flag, if T, then additionally check if ;; | 'p1' is in between 'p2' and 'p3'. ;; | [fuzz] - Fuzzy distance ;; | Return : T if the three points are colinear within the tolerance, else nil ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun GE_Collinear?( p1 p2 p3 InBetFlag fuzz / RetVal OS ) (setq OS (getvar "OSMODE") RetVal nil ) (setvar "OSMODE" 0) (cond ((not (equal p1 p2 0.001)) (command "._Ucs" "_3Point" p1 p2 (polar p1 (+ (angle p1 p2) #pb2) 10.0)) ) ((not (equal p2 p3 0.001)) (command "._Ucs" "_3Point" p2 p3 (polar p2 (+ (angle p2 p3) #pb2) 10.0)) ) (T (setq RetVal T) ) ) (if (not RetVal) (progn (setq p3 (trans p3 0 1)) (command "._Ucs" "_Previous") (if (<= (abs (cadr p3)) fuzz) (progn (if InBetFlag (progn (setq p1 (list 0.0 0.0 0.0) p2 (list (distance p1 p2) 0.0 0.0) ) (if (MI_InBetween (car p1) (car p2) (car p3)) (setq RetVal T) (setq RetVal nil) ) ) (setq RetVal T) ) ) (setq RetVal nil) ) )) (setvar "OSMODE" OS) RetVal )