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.List;
20
21 import org.apache.commons.geometry.core.RegionEmbedding;
22 import org.apache.commons.geometry.core.RegionLocation;
23 import org.apache.commons.geometry.core.internal.HyperplaneSubsets;
24 import org.apache.commons.geometry.core.partitioning.HyperplaneBoundedRegion;
25 import org.apache.commons.geometry.core.partitioning.HyperplaneSubset;
26 import org.apache.commons.geometry.spherical.oned.Point1S;
27 import org.apache.commons.numbers.core.Precision;
28
29
30
31
32 public abstract class GreatCircleSubset implements HyperplaneSubset<Point2S>, RegionEmbedding<Point2S, Point1S> {
33
34 private final GreatCircle circle;
35
36
37
38
39 GreatCircleSubset(final GreatCircle circle) {
40 this.circle = circle;
41 }
42
43
44
45
46
47 public GreatCircle getCircle() {
48 return circle;
49 }
50
51
52 @Override
53 public GreatCircle getHyperplane() {
54 return getCircle();
55 }
56
57
58 @Override
59 public Point1S toSubspace(final Point2S pt) {
60 return circle.toSubspace(pt);
61 }
62
63
64 @Override
65 public Point2S toSpace(final Point1S pt) {
66 return circle.toSpace(pt);
67 }
68
69
70 @Override
71 public boolean isFull() {
72 return getSubspaceRegion().isFull();
73 }
74
75
76 @Override
77 public boolean isEmpty() {
78 return getSubspaceRegion().isEmpty();
79 }
80
81
82 @Override
83 public double getSize() {
84 return getSubspaceRegion().getSize();
85 }
86
87
88 @Override
89 public Point2S getCentroid() {
90 final Point1S subspaceCentroid = getSubspaceRegion().getCentroid();
91 if (subspaceCentroid != null) {
92 return getCircle().toSpace(subspaceCentroid);
93 }
94 return null;
95 }
96
97
98 @Override
99 public RegionLocation classify(final Point2S pt) {
100 return HyperplaneSubsets.classifyAgainstEmbeddedRegion(pt, circle, getSubspaceRegion());
101 }
102
103
104 @Override
105 public Point2S closest(final Point2S pt) {
106 return HyperplaneSubsets.closestToEmbeddedRegion(pt, circle, getSubspaceRegion());
107 }
108
109
110 @Override
111 public abstract List<GreatArc> toConvex();
112
113
114 @Override
115 public abstract HyperplaneBoundedRegion<Point1S> getSubspaceRegion();
116
117
118
119
120
121 public Precision.DoubleEquivalence getPrecision() {
122 return circle.getPrecision();
123 }
124 }