Author Topic: LISP Challenge: Ducks in a row  (Read 6006 times)

0 Members and 1 Guest are viewing this topic.

pkohut

  • Guest
Re: LISP Challenge: Ducks in a row
« Reply #15 on: December 22, 2008, 05:22:34 PM »
Ah, mine has a side effect!  The test functions variables are being used in the IndexPoints
routines.  So the change to your test suite caught the bug.  :ugly:  Still the 3D test
and duplicate points run will fail.

Paul
« Last Edit: December 22, 2008, 05:28:32 PM by pkohut »

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: LISP Challenge: Ducks in a row
« Reply #16 on: December 22, 2008, 05:41:24 PM »
My correction too, an a little optimisation (2 lists instead of a dotted pair list)

GC = Gilles Chanteau

Code: [Select]
(defun GC:IndexPoints (control_points test_points tolerance / pl pt l1 l2)
  (vl-load-com)
  (setq pl
(entmakex
   (append
     (list
       '(0 . "lWPOLYLINE")
       '(100 . "AcDbEntity")
       '(100 . "AcDbPolyline")
       '(70 . 0)
       (cons 90 (length control_points))
     )
     (mapcar '(lambda (x) (cons 10 x)) control_points)
   )
)
  )
  (foreach p (reverse test_points)
    (setq pt (vlax-curve-getClosestPointTo pl p)
  l1 (cons (vlax-curve-getParamAtPoint pl pt) l1)
  l2 (cons (distance pt (list (car p) (cadr p))) l2)
    )
  )
  (entdel pl)
  (vl-remove-if
    '(lambda (x) (< tolerance (nth x l2)))
    (vl-sort-i l1 '<)
  )
)
Speaking English as a French Frog

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: LISP Challenge: Ducks in a row
« Reply #17 on: December 22, 2008, 06:06:09 PM »
While I don't have anything to contribute (on pseudo-holiday at the moment), this could be potentially quite useful for some of my users.  Thank you all for the ideas, I will definitely be keeping an eye on this.

Any plans for testing this with point cloud data?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: LISP Challenge: Ducks in a row
« Reply #18 on: December 23, 2008, 09:06:54 AM »
Just to cap this thread ... Giles' and Evgeniy's last entries ...

• showed performance increases, tho in the same magnitude as prior efforts
• pass the 2D and 3D tests
• fail the duplicates test

For my own use functions based upon entity creation/deletion are, while impressive performance wise, not usable for production work.

All in all a pretty fun exercise, I thank you all for your spirited participation.

Lots of functioning gray matter herein!

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: LISP Challenge: Ducks in a row
« Reply #19 on: December 23, 2008, 11:17:04 AM »
Quote
• fail the duplicates test

I don't agree.

_$ (MP:IndexPoints control_points (append test_points test_points) 1.0)
(26 2 38 14 46 22 3 27 4 28 9 33 39 15 31 7 37 13 17 41 11 35 1 25 34 10 45 21 47 23)
_$ (GC:IndexPoints control_points (append test_points test_points) 1.0)
(26 2 38 14 46 22 27 3 28 4 33 9 39 15 31 7 37 13 41 17 35 11 25 1 34 10 45 21 47 23)
_$ (EE:IndexPoints-2 control_points (append test_points test_points) 1.0)
(26 2 38 14 46 22 27 3 28 4 33 9 39 15 31 7 37 13 41 17 35 11 25 1 34 10 45 21 47 23)
_$ (EE:IndexPoints-1 control_points (append test_points test_points) 1.0)
(26 2 38 14 46 22 27 3 28 4 33 9 39 15 31 7 37 13 41 17 35 11 25 1 34 10 45 21 47 23)


The inversions as 3 27 vs 27 3, 4 28 vs 28 4, 9 33 vs 33 9 and so on, always refer to the same overlapped points (a 24 difference).
Speaking English as a French Frog

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: LISP Challenge: Ducks in a row
« Reply #20 on: December 23, 2008, 11:32:40 AM »
Don't know what to tell you Gile, when I ran my tests (which cared not if a pair was inverted, only that the pairs were in the proper sequence) it this is what I got:

NO DUPLICATES SORT
(eval (MP:INDEXPOINTS CONTROL_POINTS TEST_POINTS TOLERANCE)):
(02 14 22 03 04 09 15 07 13 17 11 01 10 21 23)

DUPLICATES SORT
(eval (E1:INDEXPOINTS CONTROL_POINTS TEST_POINTS TOLERANCE)): FAIL
(26/02  38/14  46/22  28/04  33/09  39/15  31/07 37/13  ...)

(eval (E2:INDEXPOINTS CONTROL_POINTS TEST_POINTS TOLERANCE)): FAIL
(26/02  38/14  46/22 28/04  33/09  39/15 31/07  37/13 ...)

(eval (GC:INDEXPOINTS CONTROL_POINTS TEST_POINTS TOLERANCE)): FAIL
(26/02  38/14  46/22  28/04  33/09  39/15  31/07  37/13 ...)

(eval (MP:INDEXPOINTS CONTROL_POINTS TEST_POINTS TOLERANCE)):
(26/02  38/14  46/22  03/27  04/28  09/33  39/15  31/07  ...)
 
{shrug}

I'll run fresh tests later on; gotta gun to me head right now.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: LISP Challenge: Ducks in a row
« Reply #21 on: December 23, 2008, 12:42:17 PM »

DUPLICATES SORT
(eval (E1:INDEXPOINTS CONTROL_POINTS TEST_POINTS TOLERANCE)): FAIL
(26/02  38/14  46/22  28/04  33/09  39/15  31/07 37/13  ...)

(eval (E2:INDEXPOINTS CONTROL_POINTS TEST_POINTS TOLERANCE)): FAIL
(26/02  38/14  46/22 28/04  33/09  39/15 31/07  37/13 ...)


I have received other results!

Code: [Select]
(EE:INDEXPOINTS-1 a b c)
(26 2 38 14 46 22 27 3 28 4 33 9 39 15 31 7 37 13 41 17 35 11 25 1 34 10 45 21 47 23)
(EE:INDEXPOINTS-2 a b c)
(26 2 38 14 46 22 27 3 28 4 33 9 39 15 31 7 37 13 41 17 35 11 25 1 34 10 45 21 47 23)
(GC:IndexPoints a b c)
(26 2 38 14 46 22 27 3 28 4 33 9 39 15 31 7 37 13 41 17 35 11 25 1 34 10 45 21 47 23)
(MP:IndexPoints a b c)
(26 2 38 14 46 22 3 27 4 28 9 33 39 15 31 7 37 13 17 41 11 35 1 25 34 10 45 21 47 23)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: LISP Challenge: Ducks in a row
« Reply #22 on: December 23, 2008, 12:47:33 PM »
Weird, I know I used the most current versions of all your submissions. If you're both getting some thing different than me I must be in err, so my apologies. I'll rerun anew ASAP. Forgive me / thanks for your patience.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst