Nebula
Loading...
Searching...
No Matches
euler.h
Go to the documentation of this file.
1/**** EulerAngles.h - Support for 24 angle schemes ****/
2/* Ken Shoemake, 1993 */
3#ifndef _H_EulerAngles
4#define _H_EulerAngles
5
6/*** Definitions ***/
7typedef struct {float x, y, z, w;} QuatX; /* Quaternion */
8enum QuatPart {X, Y, Z, W};
9typedef float HMatrix[4][4]; /* Right-handed, for column vectors */
10typedef QuatX EulerAngles; /* (x,y,z)=ang 1,2,3, w=order code */
11
12/*** Order type constants, constructors, extractors ***/
13 /* There are 24 possible conventions, designated by: */
14 /* o EulAxI = axis used initially */
15 /* o EulPar = parity of axis permutation */
16 /* o EulRep = repetition of initial axis as last */
17 /* o EulFrm = frame from which axes are taken */
18 /* Axes I,J,K will be a permutation of X,Y,Z. */
19 /* Axis H will be either I or K, depending on EulRep. */
20 /* Frame S takes axes from initial static frame. */
21 /* If ord = (AxI=X, Par=Even, Rep=No, Frm=S), then */
22 /* {a,b,c,ord} means Rz(c)Ry(b)Rx(a), where Rz(c)v */
23 /* rotates v around Z by c radians. */
24#define EulFrmS 0
25#define EulFrmR 1
26#define EulFrm(ord) ((unsigned)(ord)&1)
27#define EulRepNo 0
28#define EulRepYes 1
29#define EulRep(ord) (((unsigned)(ord)>>1)&1)
30#define EulParEven 0
31#define EulParOdd 1
32#define EulPar(ord) (((unsigned)(ord)>>2)&1)
33#define EulSafe "\000\001\002\000"
34#define EulNext "\001\002\000\001"
35#define EulAxI(ord) ((int)(EulSafe[(((unsigned)(ord)>>3)&3)]))
36#define EulAxJ(ord) ((int)(EulNext[EulAxI(ord)+(EulPar(ord)==EulParOdd)]))
37#define EulAxK(ord) ((int)(EulNext[EulAxI(ord)+(EulPar(ord)!=EulParOdd)]))
38#define EulAxH(ord) ((EulRep(ord)==EulRepNo)?EulAxK(ord):EulAxI(ord))
39 /* EulGetOrd unpacks all useful information about order simultaneously. */
40#define EulGetOrd(ord,i,j,k,h,n,s,f) {unsigned o=ord;f=o&1;o>>=1;s=o&1;o>>=1;\
41 n=o&1;o>>=1;i=EulSafe[o&3];j=EulNext[i+n];k=EulNext[i+1-n];h=s?k:i;}
42 /* EulOrd creates an order value between 0 and 23 from 4-tuple choices. */
43#define EulOrd(i,p,r,f) (((((((i)<<1)+(p))<<1)+(r))<<1)+(f))
44 /* Static axes */
45#define EulOrdXYZs EulOrd(X,EulParEven,EulRepNo,EulFrmS)
46#define EulOrdXYXs EulOrd(X,EulParEven,EulRepYes,EulFrmS)
47#define EulOrdXZYs EulOrd(X,EulParOdd,EulRepNo,EulFrmS)
48#define EulOrdXZXs EulOrd(X,EulParOdd,EulRepYes,EulFrmS)
49#define EulOrdYZXs EulOrd(Y,EulParEven,EulRepNo,EulFrmS)
50#define EulOrdYZYs EulOrd(Y,EulParEven,EulRepYes,EulFrmS)
51#define EulOrdYXZs EulOrd(Y,EulParOdd,EulRepNo,EulFrmS)
52#define EulOrdYXYs EulOrd(Y,EulParOdd,EulRepYes,EulFrmS)
53#define EulOrdZXYs EulOrd(Z,EulParEven,EulRepNo,EulFrmS)
54#define EulOrdZXZs EulOrd(Z,EulParEven,EulRepYes,EulFrmS)
55#define EulOrdZYXs EulOrd(Z,EulParOdd,EulRepNo,EulFrmS)
56#define EulOrdZYZs EulOrd(Z,EulParOdd,EulRepYes,EulFrmS)
57 /* Rotating axes */
58#define EulOrdZYXr EulOrd(X,EulParEven,EulRepNo,EulFrmR)
59#define EulOrdXYXr EulOrd(X,EulParEven,EulRepYes,EulFrmR)
60#define EulOrdYZXr EulOrd(X,EulParOdd,EulRepNo,EulFrmR)
61#define EulOrdXZXr EulOrd(X,EulParOdd,EulRepYes,EulFrmR)
62#define EulOrdXZYr EulOrd(Y,EulParEven,EulRepNo,EulFrmR)
63#define EulOrdYZYr EulOrd(Y,EulParEven,EulRepYes,EulFrmR)
64#define EulOrdZXYr EulOrd(Y,EulParOdd,EulRepNo,EulFrmR)
65#define EulOrdYXYr EulOrd(Y,EulParOdd,EulRepYes,EulFrmR)
66#define EulOrdYXZr EulOrd(Z,EulParEven,EulRepNo,EulFrmR)
67#define EulOrdZXZr EulOrd(Z,EulParEven,EulRepYes,EulFrmR)
68#define EulOrdXYZr EulOrd(Z,EulParOdd,EulRepNo,EulFrmR)
69#define EulOrdZYZr EulOrd(Z,EulParOdd,EulRepYes,EulFrmR)
70
71EulerAngles Eul_(float ai, float aj, float ah, int order);
76#endif
QuatX Eul_ToQuat(EulerAngles ea)
EulerAngles Eul_FromHMatrix(HMatrix M, int order)
float HMatrix[4][4]
Definition euler.h:9
QuatPart
Definition euler.h:8
@ Y
Definition euler.h:8
@ X
Definition euler.h:8
@ Z
Definition euler.h:8
@ W
Definition euler.h:8
void Eul_ToHMatrix(EulerAngles ea, HMatrix M)
EulerAngles Eul_FromQuat(QuatX q, int order)
QuatX EulerAngles
Definition euler.h:10
EulerAngles Eul_(float ai, float aj, float ah, int order)
Definition euler.h:7
float w
Definition euler.h:7