PixelLightAPI  .
EulerAngles.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: EulerAngles.h                                  *
00003  *
00004  *  Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLMATH_EULERANGLES_H__
00024 #define __PLMATH_EULERANGLES_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include "PLMath/PLMath.h"
00032 
00033 
00034 //[-------------------------------------------------------]
00035 //[ Namespace                                             ]
00036 //[-------------------------------------------------------]
00037 namespace PLMath {
00038 
00039 
00040 //[-------------------------------------------------------]
00041 //[ Forward declarations                                  ]
00042 //[-------------------------------------------------------]
00043 class Matrix3x3;
00044 class Matrix3x4;
00045 class Matrix4x4;
00046 class Quaternion;
00047 
00048 
00049 //[-------------------------------------------------------]
00050 //[ Classes                                               ]
00051 //[-------------------------------------------------------]
00052 /**
00053 *  @brief
00054 *    Static Euler angles conversion tool class
00055 *
00056 *  @remarks
00057 *    The implementation of this class is basing on the 'Euler Angle Conversion' gem from Ken Shoemake (1993)
00058 *    published in the 'Graphics Gems IV' book. The original code is available here:
00059 *    http://www.graphicsgems.org/gemsiv/euler_angle/
00060 *
00061 *  @note
00062 *    - Within PixelLight, only 'XYZs' Euler angles are used
00063 *    - When dealing with Euler angles keep care of 'gimbal lock', at http://www.sjbaker.org/steve/omniv/eulers_are_evil.html
00064 *      you will find some good information about this topic
00065 */
00066 class EulerAngles {
00067 
00068 
00069     //[-------------------------------------------------------]
00070     //[ Public definitions                                    ]
00071     //[-------------------------------------------------------]
00072     public:
00073         /**
00074         *  @brief
00075         *    Euler angles order
00076         */
00077         enum EOrder {
00078             // Static axes (takes axes from initial static frame)
00079             XYZs = 0,   /**< XYZ static axis */
00080             XYXs = 2,   /**< XYX static axis */
00081             XZYs = 4,   /**< XZY static axis */
00082             XZXs = 6,   /**< XZX static axis */
00083             YZXs = 8,   /**< YZX static axis */
00084             YZYs = 10,  /**< YZY static axis */
00085             YXZs = 12,  /**< YXZ static axis */
00086             YXYs = 14,  /**< YXY static axis */
00087             ZXYs = 16,  /**< ZXY static axis */
00088             ZXZs = 18,  /**< ZXZ static axis */
00089             ZYXs = 20,  /**< ZYX static axis */
00090             ZYZs = 22,  /**< ZYZ static axis */
00091             // Rotating axes
00092             ZYXr = 1,   /**< ZYX rotating axis */
00093             XYXr = 3,   /**< XYX rotating axis */
00094             YZXr = 5,   /**< YZX rotating axis */
00095             XZXr = 7,   /**< XZX rotating axis */
00096             XZYr = 9,   /**< XZY rotating axis */
00097             YZYr = 11,  /**< YZY rotating axis */
00098             ZXYr = 13,  /**< ZXY rotating axis */
00099             YXYr = 15,  /**< YXY rotating axis */
00100             YXZr = 17,  /**< YXZ rotating axis */
00101             ZXZr = 19,  /**< ZXZ rotating axis */
00102             XYZr = 21,  /**< XYZ rotating axis */
00103             ZYZr = 23   /**< ZYZ rotating axis */
00104         };
00105 
00106 
00107     //[-------------------------------------------------------]
00108     //[ Public static functions                               ]
00109     //[-------------------------------------------------------]
00110     public:
00111         /**
00112         *  @brief
00113         *    Sets a rotation quaternion by using three given Euler angles
00114         *
00115         *  @param[in]  fAngleX
00116         *    Rotation angle around the x axis (in radian)
00117         *    where fAngleX > 0 indicates a counterclockwise rotation in the yz-plane (if you look along -x)
00118         *  @param[in]  fAngleY
00119         *    Rotation angle around the y axis (in radian)
00120         *    where fAngleY > 0 indicates a counterclockwise rotation in the zx-plane (if you look along -y)
00121         *  @param[in]  fAngleZ
00122         *    Rotation angle around the z axis (in radian)
00123         *    where fAngleZ > 0 indicates a counterclockwise rotation in the xy-plane (if you look along -z)
00124         *  @param[out] qRotation
00125         *    Resulting rotation quaternion
00126         *  @param[in]  nOrder
00127         *    Order of the Euler angles
00128         */
00129         static PLMATH_API void ToQuaternion(float fAngleX, float fAngleY, float fAngleZ, Quaternion &qRotation, EOrder nOrder = XYZs);
00130 
00131         /**
00132         *  @brief
00133         *    Returns the Euler angles from a rotation quaternion
00134         *
00135         *  @param[in]  qRotation
00136         *    Rotation quaternion
00137         *  @param[out] fAngleX
00138         *    Will receive the rotation angle around the x axis (in radian)
00139         *  @param[out] fAngleY
00140         *    Will receive the rotation angle around the y axis (in radian)
00141         *  @param[out] fAngleZ
00142         *    Will receive the rotation angle around the z axis (in radian)
00143         *  @param[in]  nOrder
00144         *    Order of the Euler angles
00145         */
00146         static PLMATH_API void FromQuaternion(const Quaternion &qRotation, float &fAngleX, float &fAngleY, float &fAngleZ, EOrder nOrder = XYZs);
00147 
00148         /**
00149         *  @brief
00150         *    Sets a rotation matrix by using three given Euler angles
00151         *
00152         *  @param[in] fAngleX
00153         *    Rotation angle around the x axis (in radian)
00154         *    where fAngleX > 0 indicates a counterclockwise rotation in the yz-plane (if you look along -x)
00155         *  @param[in] fAngleY
00156         *    Rotation angle around the y axis (in radian)
00157         *    where fAngleY > 0 indicates a counterclockwise rotation in the zx-plane (if you look along -y)
00158         *  @param[in] fAngleZ
00159         *    Rotation angle around the z axis (in radian)
00160         *    where fAngleZ > 0 indicates a counterclockwise rotation in the xy-plane (if you look along -z)
00161         *  @param[out] mRot
00162         *    Resulting rotation matrix
00163         *  @param[in]  nOrder
00164         *    Order of the Euler angles
00165         */
00166         static PLMATH_API void ToMatrix(float fAngleX, float fAngleY, float fAngleZ, Matrix3x3 &mRot, EOrder nOrder = XYZs);
00167         static PLMATH_API void ToMatrix(float fAngleX, float fAngleY, float fAngleZ, Matrix3x4 &mRot, EOrder nOrder = XYZs);
00168         static PLMATH_API void ToMatrix(float fAngleX, float fAngleY, float fAngleZ, Matrix4x4 &mRot, EOrder nOrder = XYZs);
00169 
00170         /**
00171         *  @brief
00172         *    Returns the Euler angles from a rotation matrix
00173         *
00174         *  @param[in]  mRot
00175         *    Rotation matrix
00176         *  @param[out] fAngleX
00177         *    Will receive the rotation angle around the x axis (in radian)
00178         *  @param[out] fAngleY
00179         *    Will receive the rotation angle around the y axis (in radian)
00180         *  @param[out] fAngleZ
00181         *    Will receive the rotation angle around the z axis (in radian)
00182         *  @param[in]  nOrder
00183         *    Order of the Euler angles
00184         */
00185         static PLMATH_API void FromMatrix(const Matrix3x3 &mRot, float &fAngleX, float &fAngleY, float &fAngleZ, EOrder nOrder = XYZs);
00186         static PLMATH_API void FromMatrix(const Matrix3x4 &mRot, float &fAngleX, float &fAngleY, float &fAngleZ, EOrder nOrder = XYZs);
00187         static PLMATH_API void FromMatrix(const Matrix4x4 &mRot, float &fAngleX, float &fAngleY, float &fAngleZ, EOrder nOrder = XYZs);
00188 
00189 
00190 };
00191 
00192 
00193 //[-------------------------------------------------------]
00194 //[ Namespace                                             ]
00195 //[-------------------------------------------------------]
00196 } // PLMath
00197 
00198 
00199 #endif // __PLMATH_EULERANGLES_H__


PixelLight PixelLight 0.9.10-R1
Copyright (C) 2002-2011 by The PixelLight Team
Last modified Fri Dec 23 2011 15:50:52
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported