Message 1 of 13
Remove duplicate points from a list

Not applicable
09-09-2016
04:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Chaps,
Can anybody speed up this code that removes duplicate coordinates from a list? Six points obviously isn't a problem but I'm working mainly with 100k points.
(setq TRI_Points '((0.0 0.0 0.0) (0.0 0.0 0.0) (10.0 0.0 0.0) (10.0 0.0 0.0) (0.0 0.0 0.1) (10.0 0.0 0.0))) ; stripped to : '((0.0 0.0 0.0) (10.0 0.0 0.0) (0.0 0.0 0.1)) (setq TRI_StrippedPoints (list (car TRI_Points)) TRI_Points (cdr TRI_Points) ) (repeat (length TRI_Points) (setq TRI_checkpoint (car TRI_Points) TRI_checkX (car TRI_checkpoint) TRI_checkY (cadr TRI_checkpoint) TRI_checkZ (caddr TRI_checkpoint) TRI_check T ) (foreach TRI_temp TRI_StrippedPoints (setq TRI_tempX (car TRI_temp) TRI_tempY (cadr TRI_temp) TRI_tempZ (caddr TRI_temp) ) (if (and (equal TRI_tempX TRI_checkX 0.0001) (equal TRI_tempY TRI_checkY 0.0001) (equal TRI_tempZ TRI_checkZ 0.0001) ) (setq TRI_check nil) ) ) (if TRI_check (setq TRI_StrippedPoints (append TRI_StrippedPoints (list TRI_checkpoint))) ) (setq TRI_Points (cdr TRI_Points)) )