View Javadoc
1   /*
2    * Licensed to the Hipparchus project under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The Hipparchus project 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    *      https://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  
18  package org.hipparchus.geometry.euclidean.threed;
19  
20  import org.hipparchus.CalculusFieldElement;
21  
22  /** Enumerate for one stage of {@link RotationOrder}.
23   * @since 3.1
24   */
25  enum RotationStage {
26  
27      /** Rotation around X axis. */
28      X {
29  
30          /** {@inheritDoc} */
31          @Override
32          public Vector3D getAxis() {
33              return Vector3D.PLUS_I;
34          }
35  
36          /** {@inheritDoc} */
37          @Override
38          public double getComponent(final Vector3D v) {
39              return v.getX();
40          }
41  
42          /** {@inheritDoc} */
43          @Override
44          public <T extends CalculusFieldElement<T>> T getComponent(final FieldVector3D<T> v) {
45              return v.getX();
46          }
47  
48      },
49  
50      /** Rotation around Y axis. */
51      Y {
52  
53          /** {@inheritDoc} */
54          @Override
55          public Vector3D getAxis() {
56              return Vector3D.PLUS_J;
57          }
58  
59          /** {@inheritDoc} */
60          @Override
61          public double getComponent(final Vector3D v) {
62              return v.getY();
63          }
64  
65          /** {@inheritDoc} */
66          @Override
67          public <T extends CalculusFieldElement<T>> T getComponent(final FieldVector3D<T> v) {
68              return v.getY();
69          }
70  
71      },
72  
73      /** Rotation around Z axis. */
74      Z {
75  
76          /** {@inheritDoc} */
77          @Override
78          public Vector3D getAxis() {
79              return Vector3D.PLUS_K;
80          }
81  
82          /** {@inheritDoc} */
83          @Override
84          public double getComponent(final Vector3D v) {
85              return v.getZ();
86          }
87  
88          /** {@inheritDoc} */
89          @Override
90          public <T extends CalculusFieldElement<T>> T getComponent(final FieldVector3D<T> v) {
91              return v.getZ();
92          }
93  
94      };
95  
96      /** Get the rotation axis.
97       * @return rotation axis
98       */
99      public abstract Vector3D getAxis();
100 
101     /** Get vector component along axis.
102      * @param v vector from which component should be retrieved
103      * @return vector component along axis
104      */
105     public abstract double getComponent(Vector3D v);
106 
107     /** Get vector component along axis.
108      * @param <T> type of the field elements
109      * @param v vector from which component should be retrieved
110      * @return vector component along axis
111      */
112     public abstract <T extends CalculusFieldElement<T>> T getComponent(FieldVector3D<T> v);
113 
114 }