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: 811827 $ $Date: 2009-09-06 17:32:50 +0200 (dim. 06 sept. 2009) $ 030 * @since 1.2 031 */ 032 public final class RotationOrder { 033 034 /** Set of Cardan angles. 035 * this ordered set of rotations is around X, then around Y, then 036 * around Z 037 */ 038 public static final RotationOrder XYZ = 039 new RotationOrder("XYZ", Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_K); 040 041 /** Set of Cardan angles. 042 * this ordered set of rotations is around X, then around Z, then 043 * around Y 044 */ 045 public static final RotationOrder XZY = 046 new RotationOrder("XZY", Vector3D.PLUS_I, Vector3D.PLUS_K, Vector3D.PLUS_J); 047 048 /** Set of Cardan angles. 049 * this ordered set of rotations is around Y, then around X, then 050 * around Z 051 */ 052 public static final RotationOrder YXZ = 053 new RotationOrder("YXZ", Vector3D.PLUS_J, Vector3D.PLUS_I, Vector3D.PLUS_K); 054 055 /** Set of Cardan angles. 056 * this ordered set of rotations is around Y, then around Z, then 057 * around X 058 */ 059 public static final RotationOrder YZX = 060 new RotationOrder("YZX", Vector3D.PLUS_J, Vector3D.PLUS_K, Vector3D.PLUS_I); 061 062 /** Set of Cardan angles. 063 * this ordered set of rotations is around Z, then around X, then 064 * around Y 065 */ 066 public static final RotationOrder ZXY = 067 new RotationOrder("ZXY", Vector3D.PLUS_K, Vector3D.PLUS_I, Vector3D.PLUS_J); 068 069 /** Set of Cardan angles. 070 * this ordered set of rotations is around Z, then around Y, then 071 * around X 072 */ 073 public static final RotationOrder ZYX = 074 new RotationOrder("ZYX", Vector3D.PLUS_K, Vector3D.PLUS_J, Vector3D.PLUS_I); 075 076 /** Set of Euler angles. 077 * this ordered set of rotations is around X, then around Y, then 078 * around X 079 */ 080 public static final RotationOrder XYX = 081 new RotationOrder("XYX", Vector3D.PLUS_I, Vector3D.PLUS_J, Vector3D.PLUS_I); 082 083 /** Set of Euler angles. 084 * this ordered set of rotations is around X, then around Z, then 085 * around X 086 */ 087 public static final RotationOrder XZX = 088 new RotationOrder("XZX", Vector3D.PLUS_I, Vector3D.PLUS_K, Vector3D.PLUS_I); 089 090 /** Set of Euler angles. 091 * this ordered set of rotations is around Y, then around X, then 092 * around Y 093 */ 094 public static final RotationOrder YXY = 095 new RotationOrder("YXY", Vector3D.PLUS_J, Vector3D.PLUS_I, Vector3D.PLUS_J); 096 097 /** Set of Euler angles. 098 * this ordered set of rotations is around Y, then around Z, then 099 * 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 }