RotationStage.java

  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. package org.hipparchus.geometry.euclidean.threed;

  18. import org.hipparchus.CalculusFieldElement;

  19. /** Enumerate for one stage of {@link RotationOrder}.
  20.  * @since 3.1
  21.  */
  22. enum RotationStage {

  23.     /** Rotation around X axis. */
  24.     X {

  25.         /** {@inheritDoc} */
  26.         @Override
  27.         public Vector3D getAxis() {
  28.             return Vector3D.PLUS_I;
  29.         }

  30.         /** {@inheritDoc} */
  31.         @Override
  32.         public double getComponent(final Vector3D v) {
  33.             return v.getX();
  34.         }

  35.         /** {@inheritDoc} */
  36.         @Override
  37.         public <T extends CalculusFieldElement<T>> T getComponent(final FieldVector3D<T> v) {
  38.             return v.getX();
  39.         }

  40.     },

  41.     /** Rotation around Y axis. */
  42.     Y {

  43.         /** {@inheritDoc} */
  44.         @Override
  45.         public Vector3D getAxis() {
  46.             return Vector3D.PLUS_J;
  47.         }

  48.         /** {@inheritDoc} */
  49.         @Override
  50.         public double getComponent(final Vector3D v) {
  51.             return v.getY();
  52.         }

  53.         /** {@inheritDoc} */
  54.         @Override
  55.         public <T extends CalculusFieldElement<T>> T getComponent(final FieldVector3D<T> v) {
  56.             return v.getY();
  57.         }

  58.     },

  59.     /** Rotation around Z axis. */
  60.     Z {

  61.         /** {@inheritDoc} */
  62.         @Override
  63.         public Vector3D getAxis() {
  64.             return Vector3D.PLUS_K;
  65.         }

  66.         /** {@inheritDoc} */
  67.         @Override
  68.         public double getComponent(final Vector3D v) {
  69.             return v.getZ();
  70.         }

  71.         /** {@inheritDoc} */
  72.         @Override
  73.         public <T extends CalculusFieldElement<T>> T getComponent(final FieldVector3D<T> v) {
  74.             return v.getZ();
  75.         }

  76.     };

  77.     /** Get the rotation axis.
  78.      * @return rotation axis
  79.      */
  80.     public abstract Vector3D getAxis();

  81.     /** Get vector component along axis.
  82.      * @param v vector from which component should be retrieved
  83.      * @return vector component along axis
  84.      */
  85.     public abstract double getComponent(Vector3D v);

  86.     /** Get vector component along axis.
  87.      * @param <T> type of the field elements
  88.      * @param v vector from which component should be retrieved
  89.      * @return vector component along axis
  90.      */
  91.     public abstract <T extends CalculusFieldElement<T>> T getComponent(FieldVector3D<T> v);

  92. }