;; | ---------------------------------------------------------------------------- ;; | GE_SortByDistance ;; | ---------------------------------------------------------------------------- ;; | Function : Sort a list of points by distance from a given point ;; | Arguments: ;; | 'vlist' - List of points ;; | 'pt1' - 'Reference point for distance measurement' ;; | 'Mode' - can be either "Slope" or "Horiz" ;; | Specifies whether the distances are to be measured ;; | horizontally projected or in slope [actual]. ;; | Action : Sorts a list of points in ascending order by their distance from ;; | a given point. ;; | Updated : November 2, 1998 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun GE_SortByDistance( vlist pt1 Mode / tmpPt ) (if (= Mode "Horiz") (setq tmpPt (list (car pt1) (cadr pt1) 0.0)) (setq tmpPt pt1) ) (setq vlist (mapcar '(lambda(x) (if (= Mode "Horiz") (list (distance tmpPt (list (car x) (cadr x) 0.0)) x) (list (distance tmpPt x) x) ) ) vlist ) vlist (l_ssort vlist 0 '>) vlist (mapcar 'cadr vlist) ) )