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: 811827 $ $Date: 2009-09-06 17:32:50 +0200 (dim. 06 sept. 2009) $ 30 * @since 1.2 31 */ 32 public final class RotationOrder { 33 34 /** Set of Cardan angles. 35 * this ordered set of rotations is around X, then around Y, then 36 * around Z 37 */ 38 public static final RotationOrder XYZ = 39 new RotationOrder("XYZ", Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K); 40 41 /** Set of Cardan angles. 42 * this ordered set of rotations is around X, then around Z, then 43 * around Y 44 */ 45 public static final RotationOrder XZY = 46 new RotationOrder("XZY", Vector3D.PLUS_I, Vector3D.PLUS_K, Vector3D.PLUS_J); 47 48 /** Set of Cardan angles. 49 * this ordered set of rotations is around Y, then around X, then 50 * around Z 51 */ 52 public static final RotationOrder YXZ = 53 new RotationOrder("YXZ", Vector3D.PLUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K); 54 55 /** Set of Cardan angles. 56 * this ordered set of rotations is around Y, then around Z, then 57 * around X 58 */ 59 public static final RotationOrder YZX = 60 new RotationOrder("YZX", Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I); 61 62 /** Set of Cardan angles. 63 * this ordered set of rotations is around Z, then around X, then 64 * around Y 65 */ 66 public static final RotationOrder ZXY = 67 new RotationOrder("ZXY", Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J); 68 69 /** Set of Cardan angles. 70 * this ordered set of rotations is around Z, then around Y, then 71 * around X 72 */ 73 public static final RotationOrder ZYX = 74 new RotationOrder("ZYX", Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.PLUS_I); 75 76 /** Set of Euler angles. 77 * this ordered set of rotations is around X, then around Y, then 78 * around X 79 */ 80 public static final RotationOrder XYX = 81 new RotationOrder("XYX", Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_I); 82 83 /** Set of Euler angles. 84 * this ordered set of rotations is around X, then around Z, then 85 * around X 86 */ 87 public static final RotationOrder XZX = 88 new RotationOrder("XZX", Vector3D.PLUS_I, Vector3D.PLUS_K, Vector3D.PLUS_I); 89 90 /** Set of Euler angles. 91 * this ordered set of rotations is around Y, then around X, then 92 * around Y 93 */ 94 public static final RotationOrder YXY = 95 new RotationOrder("YXY", Vector3D.PLUS_J, Vector3D.PLUS_I, Vector3D.PLUS_J); 96 97 /** Set of Euler angles. 98 * this ordered set of rotations is around Y, then around Z, then 99 * around Y 100 */ 101 public static final RotationOrder YZY = 102 new RotationOrder("YZY", Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_J); 103 104 /** Set of Euler angles. 105 * this ordered set of rotations is around Z, then around X, then 106 * around Z 107 */ 108 public static final RotationOrder ZXZ = 109 new RotationOrder("ZXZ", Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_K); 110 111 /** Set of Euler angles. 112 * this ordered set of rotations is around Z, then around Y, then 113 * around Z 114 */ 115 public static final RotationOrder ZYZ = 116 new RotationOrder("ZYZ", Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.PLUS_K); 117 118 /** Name of the rotations order. */ 119 private final String name; 120 121 /** Axis of the first rotation. */ 122 private final Vector3D a1; 123 124 /** Axis of the second rotation. */ 125 private final Vector3D a2; 126 127 /** Axis of the third rotation. */ 128 private final Vector3D a3; 129 130 /** Private constructor. 131 * This is a utility class that cannot be instantiated by the user, 132 * so its only constructor is private. 133 * @param name name of the rotation order 134 * @param a1 axis of the first rotation 135 * @param a2 axis of the second rotation 136 * @param a3 axis of the third rotation 137 */ 138 private RotationOrder(final String name, 139 final Vector3D a1, final Vector3D a2, final Vector3D a3) { 140 this.name = name; 141 this.a1 = a1; 142 this.a2 = a2; 143 this.a3 = a3; 144 } 145 146 /** Get a string representation of the instance. 147 * @return a string representation of the instance (in fact, its name) 148 */ 149 @Override 150 public String toString() { 151 return name; 152 } 153 154 /** Get the axis of the first rotation. 155 * @return axis of the first rotation 156 */ 157 public Vector3D getA1() { 158 return a1; 159 } 160 161 /** Get the axis of the second rotation. 162 * @return axis of the second rotation 163 */ 164 public Vector3D getA2() { 165 return a2; 166 } 167 168 /** Get the axis of the second rotation. 169 * @return axis of the second rotation 170 */ 171 public Vector3D getA3() { 172 return a3; 173 } 174 175 } 176