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 */ 017package org.apache.commons.geometry.euclidean.threed.rotation; 018 019import org.apache.commons.geometry.euclidean.threed.Vector3D; 020 021/** Enum containing rotation axis sequences for use in defining 3 dimensional rotations. 022 */ 023public enum AxisSequence { 024 025 /** Set of Tait-Bryan angles around the <strong>X</strong>, <strong>Y</strong>, and 026 * <strong>Z</strong> axes in that order. 027 */ 028 XYZ(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z), 029 030 /** Set of Tait-Bryan angles around the <strong>X</strong>, <strong>Z</strong>, and 031 * <strong>Y</strong> axes in that order. 032 */ 033 XZY(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y), 034 035 /** Set of Tait-Bryan angles around the <strong>Y</strong>, <strong>X</strong>, and 036 * <strong>Z</strong> axes in that order. 037 */ 038 YXZ(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z), 039 040 /** Set of Tait-Bryan angles around the <strong>Y</strong>, <strong>Z</strong>, and 041 * <strong>X</strong> axes in that order. 042 */ 043 YZX(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X), 044 045 /** Set of Cardan angles. 046 * this ordered set of rotations is around Z, then around X, then 047 * around Y 048 */ 049 ZXY(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y), 050 051 /** Set of Tait-Bryan angles around the <strong>Z</strong>, <strong>Y</strong>, and 052 * <strong>X</strong> axes in that order. 053 */ 054 ZYX(AxisSequenceType.TAIT_BRYAN, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X), 055 056 /** Set of Euler angles around the <strong>X</strong>, <strong>Y</strong>, and 057 * <strong>X</strong> axes in that order. 058 */ 059 XYX(AxisSequenceType.EULER, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X), 060 061 /** Set of Euler angles around the <strong>X</strong>, <strong>Z</strong>, and 062 * <strong>X</strong> axes in that order. 063 */ 064 XZX(AxisSequenceType.EULER, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X), 065 066 /** Set of Euler angles around the <strong>Y</strong>, <strong>X</strong>, and 067 * <strong>Y</strong> axes in that order. 068 */ 069 YXY(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Y), 070 071 /** Set of Euler angles around the <strong>Y</strong>, <strong>Z</strong>, and 072 * <strong>Y</strong> axes in that order. 073 */ 074 YZY(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y), 075 076 /** Set of Euler angles around the <strong>Z</strong>, <strong>X</strong>, and 077 * <strong>Z</strong> axes in that order. 078 */ 079 ZXZ(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_X, Vector3D.Unit.PLUS_Z), 080 081 /** Set of Euler angles around the <strong>Z</strong>, <strong>Y</strong>, and 082 * <strong>Z</strong> axes in that order. 083 */ 084 ZYZ(AxisSequenceType.EULER, Vector3D.Unit.PLUS_Z, Vector3D.Unit.PLUS_Y, Vector3D.Unit.PLUS_Z); 085 086 /** The type of axis sequence. */ 087 private final AxisSequenceType type; 088 089 /** Axis of the first rotation. */ 090 private final Vector3D axis1; 091 092 /** Axis of the second rotation. */ 093 private final Vector3D axis2; 094 095 /** Axis of the third rotation. */ 096 private final Vector3D axis3; 097 098 /** Simple constructor. 099 * @param type the axis sequence type 100 * @param axis1 first rotation axis 101 * @param axis2 second rotation axis 102 * @param axis3 third rotation axis 103 */ 104 AxisSequence(final AxisSequenceType type, final Vector3D axis1, final Vector3D axis2, final Vector3D axis3) { 105 this.type = type; 106 107 this.axis1 = axis1; 108 this.axis2 = axis2; 109 this.axis3 = axis3; 110 } 111 112 /** Get the axis sequence type. 113 * @return the axis sequence type 114 */ 115 public AxisSequenceType getType() { 116 return type; 117 } 118 119 /** Get the first rotation axis. 120 * @return the first rotation axis 121 */ 122 public Vector3D getAxis1() { 123 return axis1; 124 } 125 126 /** Get the second rotation axis. 127 * @return the second rotation axis 128 */ 129 public Vector3D getAxis2() { 130 return axis2; 131 } 132 133 /** Get the third rotation axis. 134 * @return the third rotation axis 135 */ 136 public Vector3D getAxis3() { 137 return axis3; 138 } 139 140 /** Get an array containing the 3 rotation axes in order. 141 * @return a 3-element array containing the rotation axes in order 142 */ 143 public Vector3D[] toArray() { 144 return new Vector3D[]{axis1, axis2, axis3}; 145 } 146}