;------------- POČETAK - PODNAPUTBINA ZA IZPITIVANJE JE LI TOČKA U
MNOGOKUTU----------------------------------------------
;- mnogokut treba biti oblika (list (list y1 x1 z)...(list yn xn z) (list
y1 x1 z1))
;- tocka treba bit oblika (list yt1 xt1 zt1)
;- radnju pozivamo s (punktinpolylinie tocka mnogokut) , gdje su tocka i
mnogokut promjenljivice
;https://www.cadtutor.net/forum/topic/31650-point-inside-closed-polyline/
(defun punktinpolylinie (pointinquestion
point_list
/
)
(if (equal 0.0 (pipwinkelsumme
pointinquestion point_list) 0.0001)
nil
t
)
)
(defun pipwinkelsumme (pointinquestion
point_list
/ count
p1
p2 scheitel
winkeleins
winkelzwei
)
(setq winkeleins 0.0
scheitel (car point_list)
count 1
)
(while (< 1 (length point_list))
(setq p1 (car point_list)
p2 (cadr point_list)
point_list (cdr point_list)
winkelzwei (pipwinkelhilfe pointinquestion p1
p2)
winkelzwei (if (< 180.0 winkelzwei)
(- winkelzwei 360.0)
winkelzwei
)
winkeleins (+ winkeleins winkelzwei)
)
(setq count (1+ count))
)
(setq winkelzwei (pipwinkelhilfe pointinquestion p2 scheitel)
winkelzwei (if (< 180.0
winkelzwei)
(- winkelzwei 360.0)
winkelzwei
)
)
(+ winkeleins winkelzwei)
)
(defun pipwinkelhilfe (pointinquestion p1 p2 / alpha beta)
(setq beta (angle pointinquestion
p1)
alpha (angle
pointinquestion p2)
alpha (- alpha beta)
)
(if (< alpha 0)
(setq alpha (+ (* 2 pi) alpha))
)
(* (/ (float alpha) pi) 180.0)
)
;kraj defun podnaputbine tocumnogo------------------------------------------
;------------- KRAJ - PODNAPUTBINA ZA IZPITIVANJE JE LI TOČKA U
MNOGOKUTU----------------------------------------------