7 #pragma region Constants
9 #define EXECUTION_FREQ__HZ 120
10 #define EXECUTION_TIME__SEC (1.0/EXECUTION_FREQ__HZ)
15 #define print_err(libName, message) std::cerr << "[ERROR] " << libName << "(" << __LINE__ << "): " << message << std::endl;
16 #define print_msg(libName, message) std::cerr << "[INFO] " << libName << ": " << message << std::endl;
22 CAT_RESULT_ERROR = ( CAT_RESULT_OK + 1 ),
23 CAT_RESULT_FILE_NOT_FOUND = ( CAT_RESULT_OK + 2 ),
24 CAT_RESULT_ABORT = ( CAT_RESULT_OK + 3 )
44 inline void invertTransform(
double inM[16],
double outM[16])
68 outM[12] = -(outM[0] * x + outM[1] * y + outM[2] * z);
69 outM[13] = -(outM[4] * x + outM[5] * y + outM[6] * z);
70 outM[14] = -(outM[8] * x + outM[9] * y + outM[10] * z);
97 inline void multiplyTransforms(
double l[16],
double r[16],
double outM[16])
99 outM[0] = l[0]*r[0] + l[1]*r[4] + l[2]*r[8] + l[12]*r[3];
100 outM[1] = l[0]*r[1] + l[1]*r[5] + l[2]*r[9] + l[12]*r[7];
101 outM[2] = l[0]*r[2] + l[1]*r[6] + l[2]*r[10] + l[12]*r[11];
102 outM[12] = l[0]*r[12] + l[1]*r[13] + l[2]*r[14] + l[12]*r[15];
103 outM[4] = l[4]*r[0] + l[5]*r[4] + l[6]*r[8] + l[13]*r[3];
104 outM[5] = l[4]*r[1] + l[5]*r[5] + l[6]*r[9] + l[13]*r[7];
105 outM[6] = l[4]*r[2] + l[5]*r[6] + l[6]*r[10] + l[13]*r[11];
106 outM[13] = l[4]*r[12] + l[5]*r[13] + l[6]*r[14] + l[13]*r[15];
107 outM[8] = l[8]*r[0] + l[9]*r[4] + l[10]*r[8] + l[14]*r[3];
108 outM[9] = l[8]*r[1] + l[9]*r[5] + l[10]*r[9] + l[14]*r[7];
109 outM[10] = l[8]*r[2] + l[9]*r[6] + l[10]*r[10] + l[14]*r[11];
110 outM[14] = l[8]*r[12] + l[9]*r[13] + l[10]*r[14] + l[14]*r[15];
111 outM[3] = l[3]*r[0] + l[7]*r[4] + l[11]*r[8] + l[15]*r[3];
112 outM[7] = l[3]*r[1] + l[7]*r[5] + l[11]*r[9] + l[15]*r[7];
113 outM[11] = l[3]*r[2] + l[7]*r[6] + l[11]*r[10] + l[15]*r[11];
114 outM[15] = l[3]*r[12] + l[7]*r[13] + l[11]*r[14] + l[15]*r[15];
132 inline void extendTransform(
double inM[12],
double outM[16])
135 for(
int i = 0; i < 12; i++)
141 outM[i+col] = inM[i];
151 inline void transposeRotation(
double inM[12],
double outM[12])
167 inline void transposeRotation4x4(
double inM[16],
double outM[16])
208 inline void shrinkTransform(
double inM[16],
double outM[12])
211 for(
int i = 0; i < 12; i++)
217 outM[i] = inM[i+col];
227 inline void rotationMatrixToQuaternion(
double inM[12],
double outM[7])
233 outM[6] = std::sqrt(1 + inM[0] + (inM[4]) + inM[8])/2;
234 outM[3] = (inM[5]-inM[7])/(4*outM[6]);
235 outM[4] = (inM[6]-inM[2])/(4*outM[6]);
236 outM[5] = (inM[1]-inM[3])/(4*outM[6]);