View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) 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 ASF 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  
18  package org.apache.commons.math.geometry;
19  
20  /**
21   * This class is a utility representing a rotation order specification
22   * for Cardan or Euler angles specification.
23   *
24   * This class cannot be instanciated by the user. He can only use one
25   * of the twelve predefined supported orders as an argument to either
26   * the {@link Rotation#Rotation(RotationOrder,double,double,double)}
27   * constructor or the {@link Rotation#getAngles} method.
28   *
29   * @version $Revision: 762087 $ $Date: 2009-04-05 10:20:18 -0400 (Sun, 05 Apr 2009) $
30   * @since 1.2
31   */
32  public final class RotationOrder {
33  
34    /** Private constructor.
35     * This is a utility class that cannot be instantiated by the user,
36     * so its only constructor is private.
37     * @param name name of the rotation order
38     * @param a1 axis of the first rotation
39     * @param a2 axis of the second rotation
40     * @param a3 axis of the third rotation
41     */
42    private RotationOrder(String name,
43                          Vector3D a1, Vector3D a2, Vector3D a3) {
44      this.name = name;
45      this.a1   = a1;
46      this.a2   = a2;
47      this.a3   = a3;
48    }
49  
50    /** Get a string representation of the instance.
51     * @return a string representation of the instance (in fact, its name)
52     */
53    @Override
54    public String toString() {
55      return name;
56    }
57  
58    /** Get the axis of the first rotation.
59     * @return axis of the first rotation
60     */
61    public Vector3D getA1() {
62      return a1;
63    }
64  
65    /** Get the axis of the second rotation.
66     * @return axis of the second rotation
67     */
68    public Vector3D getA2() {
69      return a2;
70    }
71  
72    /** Get the axis of the second rotation.
73     * @return axis of the second rotation
74     */
75    public Vector3D getA3() {
76      return a3;
77    }
78  
79    /** Set of Cardan angles.
80     * this ordered set of rotations is around X, then around Y, then
81     * around Z
82     */
83    public static final RotationOrder XYZ =
84      new RotationOrder("XYZ", Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K);
85  
86    /** Set of Cardan angles.
87     * this ordered set of rotations is around X, then around Z, then
88     * around Y
89     */
90    public static final RotationOrder XZY =
91      new RotationOrder("XZY", Vector3D.PLUS_I, Vector3D.PLUS_K, Vector3D.PLUS_J);
92  
93    /** Set of Cardan angles.
94     * this ordered set of rotations is around Y, then around X, then
95     * around Z
96     */
97    public static final RotationOrder YXZ =
98      new RotationOrder("YXZ", Vector3D.PLUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K);
99  
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 }