-
Notifications
You must be signed in to change notification settings - Fork 0
/
seg_intersects_test.go
31 lines (27 loc) · 1.09 KB
/
seg_intersects_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package robust
import (
"github.com/franela/goblin"
"testing"
)
func TestRobustIntersects(t *testing.T) {
g := goblin.Goblin(t)
g.Describe("SegIntersects", func() {
g.It("test robust seg seg intersects", func() {
g.Assert(SegIntersects(af(-1, 0), af(1, 0), af(0, -1), af(0, 1))).IsTrue()
g.Assert(SegIntersects(af(0.5, 0), af(1, 0), af(0, -1), af(0, 1))).IsFalse()
g.Assert(SegIntersects(af(0, 0), af(1, 0), af(0, -1), af(0, 1))).IsTrue()
g.Assert(SegIntersects(af(0, 0), af(100000000000000020000, 1e-12),
af(1, 0), af(1e20, 1e-11))).IsTrue()
g.Assert(SegIntersects(af(0, 0), af(1e20, 1e-11),
af(1, 0), af(100000000000000020000, 1e-12))).IsFalse()
//collinear, no intersect
g.Assert(SegIntersects(af(0, 1), af(0, 2), af(0, -1), af(0, -2))).IsFalse()
//collinear, intersect
g.Assert(SegIntersects(af(0, 1), af(0, 2), af(0, 1.5), af(0, -2))).IsTrue()
//collinear, endpoint touch
g.Assert(SegIntersects(af(0, 1), af(0, 2), af(0, 1), af(0, -2))).IsTrue()
//endpoint touches
g.Assert(SegIntersects(af(0, 1), af(0, -1), af(0, 0), af(0, 1))).IsTrue()
})
})
}