31 const double sphi = sin(e->
phi);
32 const double cphi = cos(e->
phi);
33 const double stheta = sin(e->
theta);
34 const double ctheta = cos(e->
theta);
35 const double spsi = sin(e->
psi);
36 const double cpsi = cos(e->
psi);
41 RMAT_ELMT(*rm, 1, 0) = sphi * stheta * cpsi - cphi * spsi;
42 RMAT_ELMT(*rm, 1, 1) = sphi * stheta * spsi + cphi * cpsi;
44 RMAT_ELMT(*rm, 2, 0) = cphi * stheta * cpsi + sphi * spsi;
45 RMAT_ELMT(*rm, 2, 1) = cphi * stheta * spsi - sphi * cpsi;
51 const double phi2 = e->
phi / 2.0;
52 const double theta2 = e->
theta / 2.0;
53 const double psi2 = e->
psi / 2.0;
55 const double s_phi2 = sin(phi2);
56 const double c_phi2 = cos(phi2);
57 const double s_theta2 = sin(theta2);
58 const double c_theta2 = cos(theta2);
59 const double s_psi2 = sin(psi2);
60 const double c_psi2 = cos(psi2);
62 q->
qi = c_phi2 * c_theta2 * c_psi2 + s_phi2 * s_theta2 * s_psi2;
63 q->
qx = -c_phi2 * s_theta2 * s_psi2 + s_phi2 * c_theta2 * c_psi2;
64 q->
qy = c_phi2 * s_theta2 * c_psi2 + s_phi2 * c_theta2 * s_psi2;
65 q->
qz = c_phi2 * c_theta2 * s_psi2 - s_phi2 * s_theta2 * c_psi2;
70 const double qx2 = q->
qx * q->
qx;
71 const double qy2 = q->
qy * q->
qy;
72 const double qz2 = q->
qz * q->
qz;
73 const double qiqx = q->
qi * q->
qx;
74 const double qiqy = q->
qi * q->
qy;
75 const double qiqz = q->
qi * q->
qz;
76 const double qxqy = q->
qx * q->
qy;
77 const double qxqz = q->
qx * q->
qz;
78 const double qyqz = q->
qy * q->
qz;
79 const double dcm00 = 1.0 - 2.*(qy2 + qz2);
80 const double dcm01 = 2.*(qxqy + qiqz);
81 const double dcm02 = 2.*(qxqz - qiqy);
82 const double dcm12 = 2.*(qyqz + qiqx);
83 const double dcm22 = 1.0 - 2.*(qx2 + qy2);
85 e->
phi = atan2(dcm12, dcm22);
86 e->
theta = -asin(dcm02);
87 e->
psi = atan2(dcm01, dcm00);
92 const double qi2_M1_2 = q->
qi * q->
qi - 0.5;
93 const double qiqx = q->
qi * q->
qx;
94 const double qiqy = q->
qi * q->
qy;
95 const double qiqz = q->
qi * q->
qz;
96 double m01 = q->
qx * q->
qy;
97 double m02 = q->
qx * q->
qz;
98 double m12 = q->
qy * q->
qz;
100 const double m00 = qi2_M1_2 + q->
qx * q->
qx;
101 const double m10 = m01 - qiqz;
102 const double m20 = m02 + qiqy;
103 const double m21 = m12 - qiqx;
107 const double m11 = qi2_M1_2 + q->
qy * q->
qy;
108 const double m22 = qi2_M1_2 + q->
qz * q->
qz;
109 v_out->
x = 2 * (m00 * v_in->
x + m01 * v_in->
y + m02 * v_in->
z);
110 v_out->
y = 2 * (m10 * v_in->
x + m11 * v_in->
y + m12 * v_in->
z);
111 v_out->
z = 2 * (m20 * v_in->
x + m21 * v_in->
y + m22 * v_in->
z);
132 m_a2c->
m[0] = m_b2c->
m[0] * m_a2b->
m[0] + m_b2c->
m[1] * m_a2b->
m[3] + m_b2c->
m[2] * m_a2b->
m[6];
133 m_a2c->
m[1] = m_b2c->
m[0] * m_a2b->
m[1] + m_b2c->
m[1] * m_a2b->
m[4] + m_b2c->
m[2] * m_a2b->
m[7];
134 m_a2c->
m[2] = m_b2c->
m[0] * m_a2b->
m[2] + m_b2c->
m[1] * m_a2b->
m[5] + m_b2c->
m[2] * m_a2b->
m[8];
135 m_a2c->
m[3] = m_b2c->
m[3] * m_a2b->
m[0] + m_b2c->
m[4] * m_a2b->
m[3] + m_b2c->
m[5] * m_a2b->
m[6];
136 m_a2c->
m[4] = m_b2c->
m[3] * m_a2b->
m[1] + m_b2c->
m[4] * m_a2b->
m[4] + m_b2c->
m[5] * m_a2b->
m[7];
137 m_a2c->
m[5] = m_b2c->
m[3] * m_a2b->
m[2] + m_b2c->
m[4] * m_a2b->
m[5] + m_b2c->
m[5] * m_a2b->
m[8];
138 m_a2c->
m[6] = m_b2c->
m[6] * m_a2b->
m[0] + m_b2c->
m[7] * m_a2b->
m[3] + m_b2c->
m[8] * m_a2b->
m[6];
139 m_a2c->
m[7] = m_b2c->
m[6] * m_a2b->
m[1] + m_b2c->
m[7] * m_a2b->
m[4] + m_b2c->
m[8] * m_a2b->
m[7];
140 m_a2c->
m[8] = m_b2c->
m[6] * m_a2b->
m[2] + m_b2c->
m[7] * m_a2b->
m[5] + m_b2c->
m[8] * m_a2b->
m[8];
148 vb->
x = m_a2b->
m[0] * va->
x + m_a2b->
m[1] * va->
y + m_a2b->
m[2] * va->
z;
149 vb->
y = m_a2b->
m[3] * va->
x + m_a2b->
m[4] * va->
y + m_a2b->
m[5] * va->
z;
150 vb->
z = m_a2b->
m[6] * va->
x + m_a2b->
m[7] * va->
y + m_a2b->
m[8] * va->
z;
158 vb->
x = m_b2a->
m[0] * va->
x + m_b2a->
m[3] * va->
y + m_b2a->
m[6] * va->
z;
159 vb->
y = m_b2a->
m[1] * va->
x + m_b2a->
m[4] * va->
y + m_b2a->
m[7] * va->
z;
160 vb->
z = m_b2a->
m[2] * va->
x + m_b2a->
m[5] * va->
y + m_b2a->
m[8] * va->
z;
170 const double a2_1 = _a * _a - 1;
171 const double ab = _a * _b;
172 const double ac = _a * _c;
173 const double ad = _a * _d;
174 const double bc = _b * _c;
175 const double bd = _b * _d;
176 const double cd = _c * _d;