;; | ---------------------------------------------------------------------------- ;; | GE_DefAngWeed ;; | ---------------------------------------------------------------------------- ;; | Function : Weed a list based on deflection angle between this segment and ;; | next segment ;; | Arguments: ;; | 'vlist' - List to be weeded ;; | 'DeflAng' - Deflection angle to check between points. ;; | Return : Returns two lists, the first one is a list of retained points ;; | and the second is a list of points which were weeded along with ;; | their list array index (starting from 0). ;; | Comments : The first and last points of the list will never be weeded ;; | Author : Rakesh Rao, (C) 2004, Copyrights Four Dimension Technologies, ;; | Bangalore ;; | Updated : March 11, 2001 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun GE_DefAngWeed ( vlist DeflAng / nverts DelLst _vlist cnt CurPt More NextPt NextNextPt ang LastPt ) (setq nverts (length vlist) DelLst '() ) (if (<= nverts 2) (setq _vlist vlist) (progn (setq CurPt (car vlist) ; Make sure that the first [and last] points are not weeded LastPt (last vlist) More T _vlist (list CurPt) vlist (cdr vlist) cnt 0 ) (while More (setq cnt (1+ cnt) NextPt (nth 0 vlist) NextNextPt (nth 1 vlist) ) (if (and NextPt NextNextPt) (progn (setq ang (GE_AngleBetn2L CurPt NextPt NextPt NextNextPt)) (if ang (setq ang (apply 'min ang)) ) (if (and ang (< ang DeflAng)) (setq DelLst (cons NextPt DelLst)) (setq _vlist (cons NextPt _vlist) CurPt NextPt )) (setq vlist (cdr vlist)) ) (setq More nil) ) ) (if (not (equal (car _vlist) LastPt 0.001)) (setq _vlist (cons LastPt _vlist)) ) (setq _vlist (reverse _vlist)) )) (if (>= (length _vlist) 2) (list _vlist DelLst) nil ) )