1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.geometry.spherical;
18
19 import org.apache.commons.geometry.core.Region;
20 import org.apache.commons.geometry.core.RegionLocation;
21 import org.apache.commons.geometry.euclidean.threed.Vector3D;
22 import org.apache.commons.geometry.spherical.oned.Point1S;
23 import org.apache.commons.geometry.spherical.twod.Point2S;
24 import org.apache.commons.numbers.core.Precision;
25 import org.junit.jupiter.api.Assertions;
26
27
28
29 public final class SphericalTestUtils {
30
31
32 private SphericalTestUtils() {}
33
34
35
36
37
38
39 public static void assertPointsEqual(final Point1S expected, final Point1S actual, final double tolerance) {
40 final String msg = "Expected point to equal " + expected + " but was " + actual + ";";
41 Assertions.assertEquals(expected.getAzimuth(), actual.getAzimuth(), tolerance, msg);
42 }
43
44
45
46
47
48
49 public static void assertPointsEqual(final Point2S expected, final Point2S actual, final double tolerance) {
50 final String msg = "Expected point to equal " + expected + " but was " + actual + ";";
51 Assertions.assertEquals(expected.getAzimuth(), actual.getAzimuth(), tolerance, msg);
52 Assertions.assertEquals(expected.getPolar(), actual.getPolar(), tolerance, msg);
53 }
54
55
56
57
58
59
60 public static void assertPointsEq(final Point2S expected, final Point2S actual, final double tolerance) {
61 final String msg = "Expected point to be equivalent to " + expected + " but was " + actual + ";";
62 Assertions.assertTrue(expected.eq(actual, Precision.doubleEquivalenceOfEpsilon(tolerance)), msg);
63 }
64
65
66
67
68
69
70 public static void assertVectorsEqual(final Vector3D expected, final Vector3D actual, final double tolerance) {
71 final String msg = "Expected vector to equal " + expected + " but was " + actual + ";";
72 Assertions.assertEquals(expected.getX(), actual.getX(), tolerance, msg);
73 Assertions.assertEquals(expected.getY(), actual.getY(), tolerance, msg);
74 Assertions.assertEquals(expected.getZ(), actual.getZ(), tolerance, msg);
75 }
76
77
78
79
80
81
82 public static void checkClassify(final Region<Point2S> region, final RegionLocation loc, final Point2S... pts) {
83 for (final Point2S pt : pts) {
84 Assertions.assertEquals(loc, region.classify(pt), "Unexpected location for point " + pt);
85 }
86 }
87 }