Skip to content

Commit 45af5cf

Browse files
committed
ignore intersections within eps of endpoints in %intersect/tan
1 parent cb24e93 commit 45af5cf

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

geometry.lisp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,13 @@
951951
(return-from %intersect/tan nil)))
952952
;; scale so one curve is 0,0 1,0 1,1
953953
(m3 (scale (/ (vx a5)) (/ (vy a5))))
954-
(a6 (mv* m3 a5))
955-
(b6 (mv* m3 b5)))
954+
#++(a6 (mv* m3 a5))
955+
(b6 (mv* m3 b5))
956+
(eps (* 16 (* double-float-epsilon
957+
(max (abs (vx p1)) (abs (vy p1))
958+
(abs (vx pc)) (abs (vy pc))
959+
(abs (vx a2)) (abs (vy a2))
960+
(abs (vx b2)) (abs (vy b2)))))))
956961
(declare (ignore r1 r2))
957962
;; x₁ = 2t₁-t₁²
958963
;; y₁ = t₁²
@@ -1029,16 +1034,19 @@
10291034
(b (vy b6))
10301035
(t2 (/ (* 2 (- (sqrt b) 1))
10311036
(+ a b -2)))
1032-
(t1 (* t2 (sqrt b))))
1033-
(flet ((e (p2 at)
1034-
(let ((d1 (v2- pc p1))
1035-
(d2 (v2+ p1 (v2+ (v2scale pc -2) p2))))
1036-
(v2+ (v2+ (v2scale d2 (* at at))
1037-
(v2scale d1 (* 2 at)))
1038-
p1))))
1039-
(if (eql ref :a)
1040-
(v2->4 (e b2 t2) t1 t2)
1041-
(v2->4 (e a2 t2) t2 t1)))))))
1037+
(t1 (* t2 (sqrt b)))
1038+
(1-eps (- 1 eps)))
1039+
(when (and (< eps t1 1-eps)
1040+
(< eps t2 1-eps))
1041+
(flet ((e (p2 at)
1042+
(let ((d1 (v2- pc p1))
1043+
(d2 (v2+ p1 (v2+ (v2scale pc -2) p2))))
1044+
(v2+ (v2+ (v2scale d2 (* at at))
1045+
(v2scale d1 (* 2 at)))
1046+
p1))))
1047+
(if (eql ref :a)
1048+
(v2->4 (e b2 t2) t1 t2)
1049+
(v2->4 (e a2 t2) t2 t1))))))))
10421050

10431051

10441052

intersect-regression.lisp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,20 @@
691691
(ix2r (1578 1403 1664 1415 1689 1409) 1 0.6666666666666666d0
692692
(1689 1409 1663 1415 1578 1403) 1 0.3333333333333333d0
693693
NIL)
694+
(ix2 (366 210 367 212 368 213)
695+
(366.5d0 210.5d0 367 212 368 213)
696+
#(368.0d0 213.0d0 1.0d0 1.0d0))
697+
(ix2r (940 -21 940 -19 901 -32) 0 0.13333333333333333d0
698+
(866 20 940 -19 940 -21) 1 0
699+
#(940.0d0 -21.0d0 0.0d0 1.0d0)
700+
#(939.9606309949041d0 -20.888053818960884d0
701+
0.031772026518992295d0 0.9769345803771983d0))
702+
703+
(ix2 (940 -21 940 -19 901 -32)
704+
(866 20 940 -19 940 -21)
705+
#(940.0d0 -21.0d0 0.0d0 1.0d0)
706+
#(939.9606309949041d0 -20.888053818960884d0
707+
0.031772026518992295d0 0.9769345803771983d0))
694708

695709
)
696710
#++

0 commit comments

Comments
 (0)