1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.hipparchus.geometry.spherical.twod;
23
24 import org.hipparchus.geometry.euclidean.threed.Vector3D;
25 import org.hipparchus.geometry.partitioning.AbstractSubHyperplane;
26 import org.hipparchus.geometry.partitioning.Hyperplane;
27 import org.hipparchus.geometry.partitioning.Region;
28 import org.hipparchus.geometry.spherical.oned.Arc;
29 import org.hipparchus.geometry.spherical.oned.ArcsSet;
30 import org.hipparchus.geometry.spherical.oned.Sphere1D;
31 import org.hipparchus.util.FastMath;
32
33
34
35 public class SubCircle extends AbstractSubHyperplane<Sphere2D, Sphere1D> {
36
37
38
39
40
41 public SubCircle(final Hyperplane<Sphere2D> hyperplane,
42 final Region<Sphere1D> remainingRegion) {
43 super(hyperplane, remainingRegion);
44 }
45
46
47 @Override
48 protected AbstractSubHyperplane<Sphere2D, Sphere1D> buildNew(final Hyperplane<Sphere2D> hyperplane,
49 final Region<Sphere1D> remainingRegion) {
50 return new SubCircle(hyperplane, remainingRegion);
51 }
52
53
54 @Override
55 public SplitSubHyperplane<Sphere2D> split(final Hyperplane<Sphere2D> hyperplane) {
56
57 final Circle thisCircle = (Circle) getHyperplane();
58 final Circle otherCircle = (Circle) hyperplane;
59 final double angle = Vector3D.angle(thisCircle.getPole(), otherCircle.getPole());
60
61 if (angle < thisCircle.getTolerance() || angle > FastMath.PI - thisCircle.getTolerance()) {
62
63 return new SplitSubHyperplane<Sphere2D>(null, null);
64 } else {
65
66 final Arc arc = thisCircle.getInsideArc(otherCircle);
67 final ArcsSet.Split split = ((ArcsSet) getRemainingRegion()).split(arc);
68 final ArcsSet plus = split.getPlus();
69 final ArcsSet minus = split.getMinus();
70 return new SplitSubHyperplane<Sphere2D>(plus == null ? null : new SubCircle(thisCircle.copySelf(), plus),
71 minus == null ? null : new SubCircle(thisCircle.copySelf(), minus));
72 }
73
74 }
75
76 }