12 SG[0] = sq(_state.quat_nominal(0)) - sq(_state.quat_nominal(1)) - sq(_state.quat_nominal(2)) + sq(_state.quat_nominal(3));
13 SG[1] = 2*_state.quat_nominal(0)*_state.quat_nominal(2) - 2*_state.quat_nominal(1)*_state.quat_nominal(3);
14 SG[2] = 2*_state.quat_nominal(0)*_state.quat_nominal(1) + 2*_state.quat_nominal(2)*_state.quat_nominal(3);
17 SQ[0] = 0.5f * ((_state.quat_nominal(1)*SG[0]) - (_state.quat_nominal(0)*SG[2]) + (_state.quat_nominal(3)*SG[1]));
18 SQ[1] = 0.5f * ((_state.quat_nominal(0)*SG[1]) - (_state.quat_nominal(2)*SG[0]) + (_state.quat_nominal(3)*SG[2]));
19 SQ[2] = 0.5f * ((_state.quat_nominal(3)*SG[0]) - (_state.quat_nominal(1)*SG[1]) + (_state.quat_nominal(2)*SG[2]));
20 SQ[3] = 0.5f * ((_state.quat_nominal(0)*SG[0]) + (_state.quat_nominal(1)*SG[2]) + (_state.quat_nominal(2)*SG[1]));
27 P[0][0] += yaw_variance*sq(SQ[2]);
28 P[0][1] += yaw_variance*SQ[1]*SQ[2];
29 P[1][1] += yaw_variance*sq(SQ[1]);
30 P[0][2] += yaw_variance*SQ[0]*SQ[2];
31 P[1][2] += yaw_variance*SQ[0]*SQ[1];
32 P[2][2] += yaw_variance*sq(SQ[0]);
33 P[0][3] -= yaw_variance*SQ[2]*SQ[3];
34 P[1][3] -= yaw_variance*SQ[1]*SQ[3];
35 P[2][3] -= yaw_variance*SQ[0]*SQ[3];
36 P[3][3] += yaw_variance*sq(SQ[3]);
37 P[1][0] += yaw_variance*SQ[1]*SQ[2];
38 P[2][0] += yaw_variance*SQ[0]*SQ[2];
39 P[2][1] += yaw_variance*SQ[0]*SQ[1];
40 P[3][0] -= yaw_variance*SQ[2]*SQ[3];
41 P[3][1] -= yaw_variance*SQ[1]*SQ[3];
42 P[3][2] -= yaw_variance*SQ[0]*SQ[3];