1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.geometry.spherical.twod;
18
19 import java.util.Collections;
20
21 import org.apache.commons.numbers.core.Precision;
22 import org.junit.jupiter.api.Assertions;
23 import org.junit.jupiter.api.Test;
24
25 class BoundarySource2STest {
26
27 private static final double TEST_EPS = 1e-10;
28
29 private static final Precision.DoubleEquivalence TEST_PRECISION =
30 Precision.doubleEquivalenceOfEpsilon(TEST_EPS);
31
32 @Test
33 void testToList() {
34
35 final BoundarySource2S src = BoundarySource2S.of(
36 GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION),
37 GreatCircles.arcFromPoints(Point2S.PLUS_J, Point2S.PLUS_K, TEST_PRECISION)
38 );
39
40
41 final BoundaryList2S list = src.toList();
42
43
44 Assertions.assertEquals(2, list.count());
45 }
46
47 @Test
48 void testToList_noBoundaries() {
49
50 final BoundarySource2S src = BoundarySource2S.of();
51
52
53 final BoundaryList2S list = src.toList();
54
55
56 Assertions.assertEquals(0, list.count());
57 }
58
59 @Test
60 void testToTree() {
61
62 final BoundarySource2S src = BoundarySource2S.of(
63 GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION));
64
65
66 final RegionBSPTree2S tree = src.toTree();
67
68
69 Assertions.assertEquals(3, tree.count());
70 Assertions.assertFalse(tree.isFull());
71 Assertions.assertFalse(tree.isEmpty());
72 }
73
74 @Test
75 void testToTree_noBoundaries() {
76
77 final BoundarySource2S src = BoundarySource2S.of(Collections.emptyList());
78
79
80 final RegionBSPTree2S tree = src.toTree();
81
82
83 Assertions.assertEquals(1, tree.count());
84 Assertions.assertFalse(tree.isFull());
85 Assertions.assertTrue(tree.isEmpty());
86 }
87 }