Author Topic: Unique xy point list but ignore z  (Read 3647 times)

0 Members and 1 Guest are viewing this topic.

XXL66

  • Newt
  • Posts: 99
Unique xy point list but ignore z
« on: June 18, 2014, 10:32:54 AM »
hi,

i have a 3D point list and would like to remove the duplicates (with a fuzz for xy only) but it should ignore the z values doing this, however the return list should still have the z values included for the point.
 
thus points (1.0 2.0 2.1) and (1.0 2.01 3.0) or considered equal (xy with 0.01 fuzz) and the first should be returned in the list (1.0 2.0 2.1).

any ideas ? ty !



XXL66

  • Newt
  • Posts: 99
Re: Unique xy point list but ignore z
« Reply #1 on: June 18, 2014, 10:54:55 AM »
with help from LM ! ty LM !

but i'm wondering is there a inverse cdr function ? every item but the last ?  (reverse (cdr (reverse x))) ?

Code: [Select]
(defun LM:UniqueFuzzXY ( l f / x r )
    (while l
        (setq x (car l)
      x_ (list (car x) (cadr x))
              l (vl-remove-if (function (lambda ( y ) (equal x_ (list (car y) (cadr y)) f))) (cdr l))
              r (cons x r)
        )
    )
    (reverse r)
)

ymg

  • Swamp Rat
  • Posts: 725
Re: Unique xy point list but ignore z
« Reply #2 on: June 18, 2014, 11:16:47 AM »
Code: [Select]
(defun butLast (l) (reverse (cdr (reverse l))))

We call it butlast and it is exactly as you proposed.

ymg

LE3

  • Guest
Re: Unique xy point list but ignore z
« Reply #3 on: June 18, 2014, 11:22:04 AM »
^ yes, many of us (old ones or x-lispers) remember this place: http://autocad.xarch.at/news/faq/autolisp.html

Good times - indeed!.

ymg

  • Swamp Rat
  • Posts: 725
Re: Unique xy point list but ignore z
« Reply #4 on: June 18, 2014, 03:39:12 PM »
Quote
^ yes, many of us (old ones or x-lispers) remember this place: http://autocad.xarch.at/news/faq/autolisp.html

You must be my age, Luis.


ymg

LE3

  • Guest
Re: Unique xy point list but ignore z
« Reply #5 on: June 18, 2014, 04:10:24 PM »
Quote
^ yes, many of us (old ones or x-lispers) remember this place: http://autocad.xarch.at/news/faq/autolisp.html

You must be my age, Luis.


ymg

21? (hehe.... aha)... Have fun! (btw good code stuff you have posted lately)

Lee Mac

  • Seagull
  • Posts: 12313
  • London, England
Re: Unique xy point list but ignore z
« Reply #6 on: June 18, 2014, 07:06:48 PM »

roy_043

  • Water Moccasin
  • Posts: 1747
  • BricsCAD 18
Re: Unique xy point list but ignore z
« Reply #7 on: June 19, 2014, 03:55:41 AM »
Not very important but...
The variable x_ is not localized in LM:UniqueFuzzXY.

XXL66

  • Newt
  • Posts: 99
Re: Unique xy point list but ignore z
« Reply #8 on: June 19, 2014, 04:18:46 AM »
yes, but that's my fault, not LM's !

BTW LM. I use another function from you that i use in a function to create a gradient color map on a tin (hsltorgb). The doslib version works fine, but yours gives me strange results...see attached picture.
Something seems to go wrong with the conversion.

XXL66

  • Newt
  • Posts: 99
Re: Unique xy point list but ignore z
« Reply #9 on: June 19, 2014, 04:25:50 AM »
Not very important but...
The variable x_ is not localized in LM:UniqueFuzzXY.

Very important (from your site):

... Arkey (a Dutch CAD program) and BricsCAD (After chocolates, the next best Belgian export product).

 :wink:

roy_043

  • Water Moccasin
  • Posts: 1747
  • BricsCAD 18
Re: Unique xy point list but ignore z
« Reply #10 on: June 19, 2014, 08:14:02 AM »
Not very important but...
The variable x_ is not localized in LM:UniqueFuzzXY.

Very important (from your site):

... Arkey (a Dutch CAD program) and BricsCAD (After chocolates, the next best Belgian export product).

 :wink:
I agree with you that BricsCAD is a very good product. But let's not forget the excellent Belgian beers... :laugh:

XXL66

  • Newt
  • Posts: 99
Re: Unique xy point list but ignore z
« Reply #11 on: June 19, 2014, 08:42:43 AM »
Yes, belgian beers, tell me about it, but you dutch made a major leap with La Trappe (quadrupel) ...

Lee Mac

  • Seagull
  • Posts: 12313
  • London, England
Re: Unique xy point list but ignore z
« Reply #12 on: June 19, 2014, 02:18:42 PM »
BTW LM. I use another function from you that i use in a function to create a gradient color map on a tin (hsltorgb). The doslib version works fine, but yours gives me strange results...see attached picture.
Something seems to go wrong with the conversion.

Note that the DOSLib function is dos_hlstorgb, whereas my function is LM:hsl->rgb... this may be causing some problems if the saturation & luminance arguments are supplied in the wrong order.

Here is an updated version of my code to make it more concise:
Code - Auto/Visual Lisp: [Select]
  1. ;; HSL -> RGB  -  Lee Mac
  2. ;; Args: [int] 0<=h<=360, 0<=s<=100, 0<=l<=100
  3.  
  4. (defun LM:HSL->RGB ( h s l / u v )
  5.     (setq h (/ h 360.0)
  6.           s (/ s 100.0)
  7.           l (/ l 100.0)
  8.     )
  9.     (mapcar '(lambda ( x ) (fix (+ 0.5 (* 255 x))))
  10.         (cond
  11.             (   (zerop s) (list l l l))
  12.             (   (zerop l)'(0 0 0))
  13.             (   (setq v (if (< l 0.5) (* l (1+ s)) (- (+ l s) (* l s)))
  14.                       u (-  (* 2.0 l) v)
  15.                 )
  16.                 (mapcar
  17.                    '(lambda ( h )
  18.                         (setq h (rem (1+ h) 1))
  19.                         (cond
  20.                             (   (< (* 6.0 h) 1.0) (+ u (* 6.0 h (- v u))))
  21.                             (   (< (* 2.0 h) 1.0) v)
  22.                             (   (< (* 3.0 h) 2.0) (+ u (* 6.0 (- (/ 2.0 3.0) h) (- v u))))
  23.                             (   u   )
  24.                         )
  25.                     )
  26.                     (list (+ h (/ 1.0 3.0)) h (- h (/ 1.0 3.0)))
  27.                 )
  28.             )
  29.         )
  30.     )
  31. )

XXL66

  • Newt
  • Posts: 99
Re: Unique xy point list but ignore z
« Reply #13 on: June 20, 2014, 03:28:38 AM »
Oops, really need to make an appointment with the ophthalmologist !

thx !

Lee Mac

  • Seagull
  • Posts: 12313
  • London, England
Re: Unique xy point list but ignore z
« Reply #14 on: June 21, 2014, 08:39:05 AM »
Oops, really need to make an appointment with the ophthalmologist !

No worries  :-)

Do the two functions now produce identical results?