Skip to content

Commit b7cdaf2

Browse files
committed
[irteus/irtgeo.l] add comment to geo::face-to-triangle-make-simple
1 parent 5fb6cee commit b7cdaf2

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

irteus/irtgeo.l

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -471,24 +471,29 @@
471471
(mapcan #'(lambda (e)
472472
(let ((p (geo::line-intersection3 (e . pvert) (e . nvert)
473473
(car v) (cdr v))))
474-
(cond ((and (<= 0.0 (car p) 1.0)
474+
(cond ;; intersects with an edge. not mutually visible.
475+
((and (<= 0.0 (car p) 1.0)
475476
(< 0.0 (cadr p) 1.0))
476477
(list e))
478+
;; vertex is on an edge. never happen?
477479
((and (< 0.0 (car p) 1.0)
478480
(or (= 0.0 (cadr p)) (= 1.0 (cadr p))))
479481
nil) ;; not implemented yet
480-
;; vertex is shared by more than two edges. avoid intersecting.
482+
;; multiple vertices exist at the same position. avoid crossing. See https://github.com/euslisp/jskeus/pull/585#issuecomment-709988453
481483
((and (or (= 0.0 (car p)) (= 1.0 (car p)))
482484
(or (= 0.0 (cadr p)) (= 1.0 (cadr p)))
483485
(not (or (memq (car v) (send e :vertices)) (memq (cdr v) (send e :vertices)))))
484-
(let* ((ev (if (= 0.0 (car p)) (e . pvert) (e . nvert)))
486+
;; v0, v1, v2: consecutive vertices in f or h. v1 is at the same position as one of v, but not the same object.
487+
;; vt: another point of v
488+
;; If located clockwise around v1 in the order of v2 vt v0, crossing will occur.
489+
(let* ((v1 (if (= 0.0 (car p)) (e . pvert) (e . nvert)))
485490
(ein (find-if #'(lambda (e) (eq ev (e . nvert))) (flatten (append (send-all hs :edges) (send f :edges)))))
491+
(v0 (ein . pvert))
486492
(eout (find-if #'(lambda (e) (eq ev (e . pvert))) (flatten (append (send-all hs :edges) (send f :edges)))))
487-
(v0 (eout . nvert))
488-
(v1 (if (= 0.0 (cadr p)) (cdr v) (car v)))
489-
(v2 (ein . pvert)))
490-
(when (< (mod (+ (vector-angle (v- v0 ev) (v- v1 ev) (send f :normal)) 2PI) 2PI)
491-
(mod (+ (vector-angle (v- v0 ev) (v- v2 ev) (send f :normal)) 2PI) 2PI))
493+
(v2 (eout . nvert))
494+
(vt (if (= 0.0 (cadr p)) (cdr v) (car v))))
495+
(when (< (mod (+ (vector-angle (v- v2 v1) (v- vt v1) (send f :normal)) 2PI) 2PI)
496+
(mod (+ (vector-angle (v- v2 v1) (v- v0 v1) (send f :normal)) 2PI) 2PI))
492497
(list e)))))
493498
))
494499
(flatten (append (send-all hs :edges) (send f :edges)))))

0 commit comments

Comments
 (0)