# EulerAngles.h

    00001 //***************************************************************************************
    00002 //
    00003 // File supervisor: Crosswalk team
    00004 //
    00005 // Copyright 2008 Autodesk, Inc.  All rights reserved.
    00006 // Use of this software is subject to the terms of the Autodesk license agreement
    00007 // provided at the time of installation or download, or which otherwise accompanies
    00008 // this software in either electronic or hard copy form.
    00009 //
    00010 //***************************************************************************************
    00011
    00012 /**** EulerAngles.h - Support for 24 angle schemes ****/
    00013 /* Ken Shoemake, 1993 */
    00014 #ifndef _H_EulerAngles
    00015 #define _H_EulerAngles
    00016
    00017 #include <SIBCUtil.h>
    00018
    00019 extern "C"
    00020 {
    00021
    00022 #include "QuatTypes.h"
    00023 /*** Order type constants, constructors, extractors ***/
    00024     /* There are 24 possible conventions, designated by:    */
    00025     /*    o EulAxI = axis used initially            */
    00026     /*    o EulPar = parity of axis permutation         */
    00027     /*    o EulRep = repetition of initial axis as last     */
    00028     /*    o EulFrm = frame from which axes are taken        */
    00029     /* Axes I,J,K will be a permutation of X,Y,Z.       */
    00030     /* Axis H will be either I or K, depending on EulRep.   */
    00031     /* Frame S takes axes from initial static frame.        */
    00032     /* If ord = (AxI=X, Par=Even, Rep=No, Frm=S), then      */
    00033     /* {a,b,c,ord} means Rz(c)Ry(b)Rx(a), where Rz(c)v      */
    00034     /* rotates v around Z by c radians.             */
    00035 #define EulFrmS      0
    00036 #define EulFrmR      1
    00037 #define EulFrm(ord)  ((unsigned)(ord)&1)
    00038 #define EulRepNo     0
    00039 #define EulRepYes    1
    00040 #define EulRep(ord)  (((unsigned)(ord)>>1)&1)
    00041 #define EulParEven   0
    00042 #define EulParOdd    1
    00043 #define EulPar(ord)  (((unsigned)(ord)>>2)&1)
    00044 #define EulSafe      "\000\001\002\000"
    00045 #define EulNext      "\001\002\000\001"
    00046 #define EulAxI(ord)  ((int)(EulSafe[(((unsigned)(ord)>>3)&3)]))
    00047 #define EulAxJ(ord)  ((int)(EulNext[EulAxI(ord)+(EulPar(ord)==EulParOdd)]))
    00048 #define EulAxK(ord)  ((int)(EulNext[EulAxI(ord)+(EulPar(ord)!=EulParOdd)]))
    00049 #define EulAxH(ord)  ((EulRep(ord)==EulRepNo)?EulAxK(ord):EulAxI(ord))
    00050     /* EulGetOrd unpacks all useful information about order simultaneously. */
    00051 #define EulGetOrd(ord,i,j,k,h,n,s,f) {unsigned o=(int)ord;f=o&1;o>>=1;s=o&1;o>>=1; n=o&1;o>>=1;i=EulSafe[o&3];j=EulNext[i+n];k=EulNext[i+1-n];h=s?k:i;}
    00052     /* EulOrd creates an order value between 0 and 23 from 4-tuple choices. */
    00053 #define EulOrd(i,p,r,f)    (((((((i)<<1)+(p))<<1)+(r))<<1)+(f))
    00054     /* Static axes */
    00055 #define EulOrdXYZs    EulOrd(X,EulParEven,EulRepNo,EulFrmS)
    00056 #define EulOrdXYXs    EulOrd(X,EulParEven,EulRepYes,EulFrmS)
    00057 #define EulOrdXZYs    EulOrd(X,EulParOdd,EulRepNo,EulFrmS)
    00058 #define EulOrdXZXs    EulOrd(X,EulParOdd,EulRepYes,EulFrmS)
    00059 #define EulOrdYZXs    EulOrd(Y,EulParEven,EulRepNo,EulFrmS)
    00060 #define EulOrdYZYs    EulOrd(Y,EulParEven,EulRepYes,EulFrmS)
    00061 #define EulOrdYXZs    EulOrd(Y,EulParOdd,EulRepNo,EulFrmS)
    00062 #define EulOrdYXYs    EulOrd(Y,EulParOdd,EulRepYes,EulFrmS)
    00063 #define EulOrdZXYs    EulOrd(Z,EulParEven,EulRepNo,EulFrmS)
    00064 #define EulOrdZXZs    EulOrd(Z,EulParEven,EulRepYes,EulFrmS)
    00065 #define EulOrdZYXs    EulOrd(Z,EulParOdd,EulRepNo,EulFrmS)
    00066 #define EulOrdZYZs    EulOrd(Z,EulParOdd,EulRepYes,EulFrmS)
    00067     /* Rotating axes */
    00068 #define EulOrdZYXr    EulOrd(X,EulParEven,EulRepNo,EulFrmR)
    00069 #define EulOrdXYXr    EulOrd(X,EulParEven,EulRepYes,EulFrmR)
    00070 #define EulOrdYZXr    EulOrd(X,EulParOdd,EulRepNo,EulFrmR)
    00071 #define EulOrdXZXr    EulOrd(X,EulParOdd,EulRepYes,EulFrmR)
    00072 #define EulOrdXZYr    EulOrd(Y,EulParEven,EulRepNo,EulFrmR)
    00073 #define EulOrdYZYr    EulOrd(Y,EulParEven,EulRepYes,EulFrmR)
    00074 #define EulOrdZXYr    EulOrd(Y,EulParOdd,EulRepNo,EulFrmR)
    00075 #define EulOrdYXYr    EulOrd(Y,EulParOdd,EulRepYes,EulFrmR)
    00076 #define EulOrdYXZr    EulOrd(Z,EulParEven,EulRepNo,EulFrmR)
    00077 #define EulOrdZXZr    EulOrd(Z,EulParEven,EulRepYes,EulFrmR)
    00078 #define EulOrdXYZr    EulOrd(Z,EulParOdd,EulRepNo,EulFrmR)
    00079 #define EulOrdZYZr    EulOrd(Z,EulParOdd,EulRepYes,EulFrmR)
    00080
    00081 XSICOREEXPORT EulerAngles Eul_(float ai, float aj, float ah, int order);
    00082 XSICOREEXPORT Quat Eul_ToQuat(EulerAngles ea);
    00083 XSICOREEXPORT void Eul_ToHMatrix(EulerAngles ea, HMatrix M);
    00084 XSICOREEXPORT EulerAngles Eul_FromHMatrix(HMatrix M, int order);
    00085 XSICOREEXPORT EulerAngles Eul_FromQuat(Quat q, int order);
    00086 XSICOREEXPORT void Quat_ToHMatrix(Quat q, HMatrix M);
    00087
    00088 }
    00089
    00090 #endif
    00091
    00092