1 /* Copyright 2002-2025 CS GROUP
2 * Licensed to CS GROUP (CS) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * CS licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.orekit.models.earth.tessellation;
18
19 import org.hipparchus.geometry.euclidean.threed.Vector3D;
20
21 /** Enumerate for neighboring directions in a {@link Mesh}.
22 * @author Luc Maisonobe
23 */
24 enum Direction {
25
26 /** Along tile in the plus direction. */
27 PLUS_ALONG() {
28
29 /** {@inheritDoc} */
30 @Override
31 public Direction next() {
32 return PLUS_ACROSS;
33 }
34
35 /** {@inheritDoc} */
36 @Override
37 public int neighborAlongIndex(final Mesh.Node base) {
38 return base.getAlongIndex() + 1;
39 }
40
41 /** {@inheritDoc} */
42 @Override
43 public Vector3D motion(final Mesh.Node base,
44 final double alongDistance, final double acrossDistance) {
45 return new Vector3D(alongDistance, base.getAlong());
46 }
47
48 },
49
50 /** Along tile in the minus direction. */
51 MINUS_ALONG() {
52
53 /** {@inheritDoc} */
54 @Override
55 public Direction next() {
56 return MINUS_ACROSS;
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public int neighborAlongIndex(final Mesh.Node base) {
62 return base.getAlongIndex() - 1;
63 }
64
65 /** {@inheritDoc} */
66 @Override
67 public Vector3D motion(final Mesh.Node base,
68 final double alongDistance, final double acrossDistance) {
69 return new Vector3D(-alongDistance, base.getAlong());
70 }
71
72 },
73
74 /** Across tile in the plus direction. */
75 PLUS_ACROSS() {
76
77 /** {@inheritDoc} */
78 @Override
79 public Direction next() {
80 return MINUS_ALONG;
81 }
82
83 /** {@inheritDoc} */
84 @Override
85 public int neighborAcrossIndex(final Mesh.Node base) {
86 return base.getAcrossIndex() + 1;
87 }
88
89 /** {@inheritDoc} */
90 @Override
91 public Vector3D motion(final Mesh.Node base,
92 final double alongDistance, final double acrossDistance) {
93 return new Vector3D(acrossDistance, base.getAcross());
94 }
95
96 },
97
98 /** Across tile in the minus direction. */
99 MINUS_ACROSS() {
100
101 /** {@inheritDoc} */
102 @Override
103 public Direction next() {
104 return PLUS_ALONG;
105 }
106
107 /** {@inheritDoc} */
108 @Override
109 public int neighborAcrossIndex(final Mesh.Node base) {
110 return base.getAcrossIndex() - 1;
111 }
112
113 /** {@inheritDoc} */
114 @Override
115 public Vector3D motion(final Mesh.Node base,
116 final double alongDistance, final double acrossDistance) {
117 return new Vector3D(-acrossDistance, base.getAcross());
118 }
119
120 };
121
122 /** Get the next direction in counterclockwise order.
123 * @return next direction
124 */
125 public abstract Direction next();
126
127 /** Get the along index of neighbor.
128 * @param base base node
129 * @return along index of neighbor node
130 */
131 public int neighborAlongIndex(final Mesh.Node base) {
132 return base.getAlongIndex();
133 }
134
135 /** Get the across index of neighbor.
136 * @param base base node
137 * @return across index of neighbor node
138 */
139 public int neighborAcrossIndex(final Mesh.Node base) {
140 return base.getAcrossIndex();
141 }
142
143 /** Get the motion towards neighbor.
144 * @param base base node
145 * @param alongDistance distance for along tile motions
146 * @param acrossDistance distance for across tile motions
147 * @return motion towards neighbor
148 */
149 public abstract Vector3D motion(Mesh.Node base, double alongDistance, double acrossDistance);
150
151 }