Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
ConvexHull----bug?
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: ConvexHull----bug? (Read 1640 times)
0 Members and 1 Guest are viewing this topic.
well20152016
Newt
Posts: 130
ConvexHull----bug?
«
on:
January 04, 2019, 06:08:09 AM »
Code - Auto/Visual Lisp:
[Select]
(
defun
c:test
(
)
(
setq
lst
(
LM:ConvexHull
(
mapcar
'
cdr
(
vl
-
remove
-
if
-
not
'
(
lambda
(
x
)
(
=
(
car
x
)
10
)
)
(
entget
(
car
(
entsel
)
)
)
)
)
)
)
(
entmakex
(
append
(
list
(
cons
0
"LWPOLYLINE"
)
(
cons
100
"AcDbEntity"
)
(
cons
100
"AcDbPolyline"
)
(
cons
90
(
length
lst
)
)
(
cons
70
1
)
(
cons
62
1
)
)
(
mapcar
(
function
(
lambda
(
p
)
(
cons
10
p
)
)
)
lst
)
)
)
)
;; Convex Hull - Lee Mac
;; Implements the Graham Scan Algorithm to return the Convex Hull of a list of points.
(
defun
LM:ConvexHull
(
lst
/
ch p0
)
(
cond
(
(
<
(
length
lst
)
4
)
lst
)
(
(
setq
p0
(
car
lst
)
)
(
foreach
p1
(
cdr
lst
)
(
if
(
or
(
<
(
cadr
p1
)
(
cadr
p0
)
)
(
and
(
equal
(
cadr
p1
)
(
cadr
p0
)
1e
-
8
)
(
<
(
car
p1
)
(
car
p0
)
)
)
)
(
setq
p0 p1
)
)
)
(
setq
lst
(
vl-sort
lst
(
function
(
lambda
(
a b
/
c d
)
(
if
(
equal
(
setq
c
(
angle
p0 a
)
)
(
setq
d
(
angle
p0 b
)
)
1e
-
8
)
(
<
(
distance
p0 a
)
(
distance
p0 b
)
)
(
<
c d
)
)
)
)
)
)
(
setq
ch
(
list
(
caddr
lst
)
(
cadr
lst
)
(
car
lst
)
)
)
(
foreach
pt
(
cdddr
lst
)
(
setq
ch
(
cons
pt ch
)
)
(
while
(
and
(
caddr
ch
)
(
LM:Clockwise
-
p
(
caddr
ch
)
(
cadr
ch
)
pt
)
)
(
setq
ch
(
cons
pt
(
cddr
ch
)
)
)
)
)
ch
)
)
)
;; Clockwise-p - Lee Mac
;; Returns T if p1,p2,p3 are clockwise oriented or collinear
(
defun
LM:Clockwise
-
p
(
p1 p2 p3
)
(
<
(
-
(
*
(
-
(
car
p2
)
(
car
p1
)
)
(
-
(
cadr
p3
)
(
cadr
p1
)
)
)
(
*
(
-
(
cadr
p2
)
(
cadr
p1
)
)
(
-
(
car
p3
)
(
car
p1
)
)
)
)
1e
-
8
)
)
Logged
ribarm
Gator
Posts: 3257
Marko Ribar, architect
WWW
Re: ConvexHull----bug?
«
Reply #1 on:
January 04, 2019, 06:20:26 AM »
Refer to this post :
http://www.theswamp.org/index.php?topic=53116.msg578882#msg578882
Also for ConvexHull - pts on Hull refer to my latest codes posted for TSP started by Evgeniy Elpanov
HTH., M.R.
Logged
Marko Ribar, d.i.a.
(graduated engineer of architecture)
M.R. on Youtube
well20152016
Newt
Posts: 130
Re: ConvexHull----bug?
«
Reply #2 on:
January 04, 2019, 07:00:05 AM »
thank!
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
ConvexHull----bug?