getRotationMatrix method
Implementation
Matrix4 getRotationMatrix(Vector3 gravity, Vector3 geomagnetic) {
Vector3 a = gravity.normalized();
Vector3 e = geomagnetic.normalized();
Vector3 h = e.cross(a).normalized();
Vector3 m = a.cross(h).normalized();
return Matrix4(
h.x, m.x, a.x, 0, //
h.y, m.y, a.y, 0,
h.z, m.z, a.z, 0,
0, 0, 0, 1,
);
}