001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package org.apache.commons.math.geometry;
019    
020    /**
021     * This class is a utility representing a rotation order specification
022     * for Cardan or Euler angles specification.
023     *
024     * This class cannot be instanciated by the user. He can only use one
025     * of the twelve predefined supported orders as an argument to either
026     * the {@link Rotation#Rotation(RotationOrder,double,double,double)}
027     * constructor or the {@link Rotation#getAngles} method.
028     *
029     * @version $Revision: 762087 $ $Date: 2009-04-05 10:20:18 -0400 (Sun, 05 Apr 2009) $
030     * @since 1.2
031     */
032    public final class RotationOrder {
033    
034      /** Private constructor.
035       * This is a utility class that cannot be instantiated by the user,
036       * so its only constructor is private.
037       * @param name name of the rotation order
038       * @param a1 axis of the first rotation
039       * @param a2 axis of the second rotation
040       * @param a3 axis of the third rotation
041       */
042      private RotationOrder(String name,
043                            Vector3D a1, Vector3D a2, Vector3D a3) {
044        this.name = name;
045        this.a1   = a1;
046        this.a2   = a2;
047        this.a3   = a3;
048      }
049    
050      /** Get a string representation of the instance.
051       * @return a string representation of the instance (in fact, its name)
052       */
053      @Override
054      public String toString() {
055        return name;
056      }
057    
058      /** Get the axis of the first rotation.
059       * @return axis of the first rotation
060       */
061      public Vector3D getA1() {
062        return a1;
063      }
064    
065      /** Get the axis of the second rotation.
066       * @return axis of the second rotation
067       */
068      public Vector3D getA2() {
069        return a2;
070      }
071    
072      /** Get the axis of the second rotation.
073       * @return axis of the second rotation
074       */
075      public Vector3D getA3() {
076        return a3;
077      }
078    
079      /** Set of Cardan angles.
080       * this ordered set of rotations is around X, then around Y, then
081       * around Z
082       */
083      public static final RotationOrder XYZ =
084        new RotationOrder("XYZ", Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K);
085    
086      /** Set of Cardan angles.
087       * this ordered set of rotations is around X, then around Z, then
088       * around Y
089       */
090      public static final RotationOrder XZY =
091        new RotationOrder("XZY", Vector3D.PLUS_I, Vector3D.PLUS_K, Vector3D.PLUS_J);
092    
093      /** Set of Cardan angles.
094       * this ordered set of rotations is around Y, then around X, then
095       * around Z
096       */
097      public static final RotationOrder YXZ =
098        new RotationOrder("YXZ", Vector3D.PLUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K);
099    
100      /** Set of Cardan angles.
101       * this ordered set of rotations is around Y, then around Z, then
102       * around X
103       */
104      public static final RotationOrder YZX =
105        new RotationOrder("YZX", Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I);
106    
107      /** Set of Cardan angles.
108       * this ordered set of rotations is around Z, then around X, then
109       * around Y
110       */
111      public static final RotationOrder ZXY =
112        new RotationOrder("ZXY", Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J);
113    
114      /** Set of Cardan angles.
115       * this ordered set of rotations is around Z, then around Y, then
116       * around X
117       */
118      public static final RotationOrder ZYX =
119        new RotationOrder("ZYX", Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.PLUS_I);
120    
121      /** Set of Euler angles.
122       * this ordered set of rotations is around X, then around Y, then
123       * around X
124       */
125      public static final RotationOrder XYX =
126        new RotationOrder("XYX", Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_I);
127    
128      /** Set of Euler angles.
129       * this ordered set of rotations is around X, then around Z, then
130       * around X
131       */
132      public static final RotationOrder XZX =
133        new RotationOrder("XZX", Vector3D.PLUS_I, Vector3D.PLUS_K, Vector3D.PLUS_I);
134    
135      /** Set of Euler angles.
136       * this ordered set of rotations is around Y, then around X, then
137       * around Y
138       */
139      public static final RotationOrder YXY =
140        new RotationOrder("YXY", Vector3D.PLUS_J, Vector3D.PLUS_I, Vector3D.PLUS_J);
141    
142      /** Set of Euler angles.
143       * this ordered set of rotations is around Y, then around Z, then
144       * around Y
145       */
146      public static final RotationOrder YZY =
147        new RotationOrder("YZY", Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_J);
148    
149      /** Set of Euler angles.
150       * this ordered set of rotations is around Z, then around X, then
151       * around Z
152       */
153      public static final RotationOrder ZXZ =
154        new RotationOrder("ZXZ", Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_K);
155    
156      /** Set of Euler angles.
157       * this ordered set of rotations is around Z, then around Y, then
158       * around Z
159       */
160      public static final RotationOrder ZYZ =
161        new RotationOrder("ZYZ", Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.PLUS_K);
162    
163      /** Name of the rotations order. */
164      private final String name;
165    
166      /** Axis of the first rotation. */
167      private final Vector3D a1;
168    
169      /** Axis of the second rotation. */
170      private final Vector3D a2;
171    
172      /** Axis of the third rotation. */
173      private final Vector3D a3;
174    
175    }