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: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
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 public String toString() {
54 return name;
55 }
56
57 /** Get the axis of the first rotation.
58 * @return axis of the first rotation
59 */
60 public Vector3D getA1() {
61 return a1;
62 }
63
64 /** Get the axis of the second rotation.
65 * @return axis of the second rotation
66 */
67 public Vector3D getA2() {
68 return a2;
69 }
70
71 /** Get the axis of the second rotation.
72 * @return axis of the second rotation
73 */
74 public Vector3D getA3() {
75 return a3;
76 }
77
78 /** Set of Cardan angles.
79 * this ordered set of rotations is around X, then around Y, then
80 * around Z
81 */
82 public static final RotationOrder XYZ =
83 new RotationOrder("XYZ", Vector3D.plusI, Vector3D.plusJ, Vector3D.plusK);
84
85 /** Set of Cardan angles.
86 * this ordered set of rotations is around X, then around Z, then
87 * around Y
88 */
89 public static final RotationOrder XZY =
90 new RotationOrder("XZY", Vector3D.plusI, Vector3D.plusK, Vector3D.plusJ);
91
92 /** Set of Cardan angles.
93 * this ordered set of rotations is around Y, then around X, then
94 * around Z
95 */
96 public static final RotationOrder YXZ =
97 new RotationOrder("YXZ", Vector3D.plusJ, Vector3D.plusI, Vector3D.plusK);
98
99 /** Set of Cardan angles.
100 * this ordered set of rotations is around Y, then around Z, then
101 * around X
102 */
103 public static final RotationOrder YZX =
104 new RotationOrder("YZX", Vector3D.plusJ, Vector3D.plusK, Vector3D.plusI);
105
106 /** Set of Cardan angles.
107 * this ordered set of rotations is around Z, then around X, then
108 * around Y
109 */
110 public static final RotationOrder ZXY =
111 new RotationOrder("ZXY", Vector3D.plusK, Vector3D.plusI, Vector3D.plusJ);
112
113 /** Set of Cardan angles.
114 * this ordered set of rotations is around Z, then around Y, then
115 * around X
116 */
117 public static final RotationOrder ZYX =
118 new RotationOrder("ZYX", Vector3D.plusK, Vector3D.plusJ, Vector3D.plusI);
119
120 /** Set of Euler angles.
121 * this ordered set of rotations is around X, then around Y, then
122 * around X
123 */
124 public static final RotationOrder XYX =
125 new RotationOrder("XYX", Vector3D.plusI, Vector3D.plusJ, Vector3D.plusI);
126
127 /** Set of Euler angles.
128 * this ordered set of rotations is around X, then around Z, then
129 * around X
130 */
131 public static final RotationOrder XZX =
132 new RotationOrder("XZX", Vector3D.plusI, Vector3D.plusK, Vector3D.plusI);
133
134 /** Set of Euler angles.
135 * this ordered set of rotations is around Y, then around X, then
136 * around Y
137 */
138 public static final RotationOrder YXY =
139 new RotationOrder("YXY", Vector3D.plusJ, Vector3D.plusI, Vector3D.plusJ);
140
141 /** Set of Euler angles.
142 * this ordered set of rotations is around Y, then around Z, then
143 * around Y
144 */
145 public static final RotationOrder YZY =
146 new RotationOrder("YZY", Vector3D.plusJ, Vector3D.plusK, Vector3D.plusJ);
147
148 /** Set of Euler angles.
149 * this ordered set of rotations is around Z, then around X, then
150 * around Z
151 */
152 public static final RotationOrder ZXZ =
153 new RotationOrder("ZXZ", Vector3D.plusK, Vector3D.plusI, Vector3D.plusK);
154
155 /** Set of Euler angles.
156 * this ordered set of rotations is around Z, then around Y, then
157 * around Z
158 */
159 public static final RotationOrder ZYZ =
160 new RotationOrder("ZYZ", Vector3D.plusK, Vector3D.plusJ, Vector3D.plusK);
161
162 /** Name of the rotations order. */
163 private final String name;
164
165 /** Axis of the first rotation. */
166 private final Vector3D a1;
167
168 /** Axis of the second rotation. */
169 private final Vector3D a2;
170
171 /** Axis of the third rotation. */
172 private final Vector3D a3;
173
174 }