Examples of list:
(( 0.0 0.0 0.0) ( 0.0 30.0 0.0) ( 15.0 30.0 0.0) ( 15.0 80.0 0.0) ( 35.0 80.0 0.0) ( 35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0))
((105.0 0.0 0.0) ( 0.0 0.0 0.0) ( 0.0 30.0 0.0) ( 15.0 30.0 0.0) ( 15.0 80.0 0.0) ( 35.0 80.0 0.0) ( 35.0 30.0 0.0) (105.0 30.0 0.0))
((105.0 30.0 0.0) (105.0 0.0 0.0) ( 0.0 0.0 0.0) ( 0.0 30.0 0.0) ( 15.0 30.0 0.0) ( 15.0 80.0 0.0) ( 35.0 80.0 0.0) ( 35.0 30.0 0.0))
(( 35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) ( 0.0 0.0 0.0) ( 0.0 30.0 0.0) ( 15.0 30.0 0.0) ( 15.0 80.0 0.0) ( 35.0 80.0 0.0)) ;<<<<
(( 35.0 80.0 0.0) ( 35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) ( 0.0 0.0 0.0) ( 0.0 30.0 0.0) ( 15.0 30.0 0.0) ( 15.0 80.0 0.0))
(( 15.0 80.0 0.0) ( 35.0 80.0 0.0) ( 35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) ( 0.0 0.0 0.0) ( 0.0 30.0 0.0) ( 15.0 30.0 0.0))
(( 15.0 30.0 0.0) ( 15.0 80.0 0.0) ( 35.0 80.0 0.0) ( 35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) ( 0.0 0.0 0.0) ( 0.0 30.0 0.0))
(( 0.0 30.0 0.0) ( 15.0 30.0 0.0) ( 15.0 80.0 0.0) ( 35.0 80.0 0.0) ( 35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) ( 0.0 0.0 0.0))
Each list must give this result:
(( 35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) ( 0.0 0.0 0.0) ( 0.0 30.0 0.0) ( 15.0 30.0 0.0) ( 15.0 80.0 0.0) ( 35.0 80.0 0.0))
Marc'Thanks Marko, for "pair of greater distances" I don't mean the sum but the highest pair of values (I don't know how to explain better) but maybe this is not possible ...
(105+30) > (70+50)
According to your picture, you proposed wrong vertex for start (it should be IMHO LR - lower right point)...
(defun foo ( l / dl pairs pair pos p )
(setq dl (mapcar '(lambda ( a b ) (distance a b)) l (append (cdr l) (list (car l)))))
(setq pairs (mapcar '(lambda ( a b ) (list a b)) dl (append (cdr dl) (list (car dl)))))
(setq pair (car (vl-sort (vl-remove-if '(lambda ( x ) (vl-some '(lambda ( y ) (< y 40.0)) x)) pairs) '(lambda ( a b ) (> (+ (car a) (cadr a)) (+ (car b) (cadr b)))))))
(setq pos (vl-position pair pairs))
(setq p (nth (1+ pos) (append l l)))
(append (member p l) (reverse (cdr (member p (reverse l)))))
)
(princ (foo '((0.0 0.0 0.0) (0.0 30.0 0.0) (15.0 30.0 0.0) (15.0 80.0 0.0) (35.0 80.0 0.0) (35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0))))
(princ (foo '((105.0 0.0 0.0) (0.0 0.0 0.0) (0.0 30.0 0.0) (15.0 30.0 0.0) (15.0 80.0 0.0) (35.0 80.0 0.0) (35.0 30.0 0.0) (105.0 30.0 0.0))))
(princ (foo '((105.0 30.0 0.0) (105.0 0.0 0.0) (0.0 0.0 0.0) (0.0 30.0 0.0) (15.0 30.0 0.0) (15.0 80.0 0.0) (35.0 80.0 0.0) (35.0 30.0 0.0))))
(princ (foo '((35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) (0.0 0.0 0.0) (0.0 30.0 0.0) (15.0 30.0 0.0) (15.0 80.0 0.0) (35.0 80.0 0.0))))
(princ (foo '((35.0 80.0 0.0) (35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) (0.0 0.0 0.0) (0.0 30.0 0.0) (15.0 30.0 0.0) (15.0 80.0 0.0))))
(princ (foo '((15.0 80.0 0.0) (35.0 80.0 0.0) (35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) (0.0 0.0 0.0) (0.0 30.0 0.0) (15.0 30.0 0.0))))
(princ (foo '((15.0 30.0 0.0) (15.0 80.0 0.0) (35.0 80.0 0.0) (35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) (0.0 0.0 0.0) (0.0 30.0 0.0))))
(princ (foo '((0.0 30.0 0.0) (15.0 30.0 0.0) (15.0 80.0 0.0) (35.0 80.0 0.0) (35.0 30.0 0.0) (105.0 30.0 0.0) (105.0 0.0 0.0) (0.0 0.0 0.0))))