+void print_3x3_matrix(const Eigen::Matrix3d& m)
+{
+ printf("%6.4f %6.4f %6.4f\n", m(0,0), m(0,1), m(0,2));
+ printf("%6.4f %6.4f %6.4f\n", m(1,0), m(1,1), m(1,2));
+ printf("%6.4f %6.4f %6.4f\n", m(2,0), m(2,1), m(2,2));
+ printf("\n");
+}
+
+string output_glsl_mat3(const string &name, const Eigen::Matrix3d &m)
+{
+ char buf[1024];
+ sprintf(buf,
+ "const mat3 %s = mat3(\n"
+ " %.8f, %.8f, %.8f,\n"
+ " %.8f, %.8f, %.8f,\n"
+ " %.8f, %.8f, %.8f);\n\n",
+ name.c_str(),
+ m(0,0), m(1,0), m(2,0),
+ m(0,1), m(1,1), m(2,1),
+ m(0,2), m(1,2), m(2,2));
+ return buf;
+}
+
+void combine_two_samples(float w1, float w2, float *offset, float *total_weight, float *sum_sq_error)