#ifndef V3D_MATH_UTILITIES_H
#define V3D_MATH_UTILITIES_H
#include "Math/v3d_linear.h"
#include "Math/v3d_linear_utils.h"
#include <vector>
namespace V3D
{
template <typename Vec, typename Mat>
inline void
createRotationMatrixRodriguez(Vec const& omega, Mat& R)
{
assert(omega.size() == 3);
assert(R.num_rows() == 3);
assert(R.num_cols() == 3);
double const theta = norm_L2(omega);
makeIdentityMatrix(R);
if (fabs(theta) > 1e-6)
{
Matrix3x3d J, J2;
makeCrossProductMatrix(omega, J);
multiply_A_B(J, J, J2);
double const c1 = sin(theta)/theta;
double const c2 = (1-cos(theta))/(theta*theta);
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
R[i][j] += c1*J[i][j] + c2*J2[i][j];
}
}
template <typename T> inline double sqr(T x) { return x*x; }
}
#endif