31 #ifndef CERES_EXAMPLES_POSE_GRAPH_3D_EIGEN_QUATERNION_PARAMETERIZATION_H_ 32 #define CERES_EXAMPLES_POSE_GRAPH_3D_EIGEN_QUATERNION_PARAMETERIZATION_H_ 34 #include "ceres/local_parameterization.h" 52 virtual bool Plus(
const double* x_ptr,
54 double* x_plus_delta_ptr)
const 56 Eigen::Map<Eigen::Quaterniond> x_plus_delta(x_plus_delta_ptr);
57 Eigen::Map<const Eigen::Quaterniond> x(x_ptr);
59 const double norm_delta =
60 sqrt(delta[0] * delta[0] + delta[1] * delta[1] + delta[2] * delta[2]);
61 if (norm_delta > 0.0) {
62 const double sin_delta_by_delta =
sin(norm_delta) / norm_delta;
65 Eigen::Quaterniond delta_q(
cos(norm_delta),
66 sin_delta_by_delta * delta[0],
67 sin_delta_by_delta * delta[1],
68 sin_delta_by_delta * delta[2]);
69 x_plus_delta = delta_q * x;
77 double* jacobian)
const{
78 jacobian[0] = x[3]; jacobian[1] = x[2]; jacobian[2] = -x[1];
79 jacobian[3] = -x[2]; jacobian[4] = x[3]; jacobian[5] = x[0];
80 jacobian[6] = x[1]; jacobian[7] = -x[0]; jacobian[8] = x[3];
81 jacobian[9] = -x[0]; jacobian[10] = -x[1]; jacobian[11] = -x[2];
90 #endif // CERES_EXAMPLES_POSE_GRAPH_3D_EIGEN_QUATERNION_PARAMETERIZATION_H_ virtual int LocalSize() const
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &x)
virtual int GlobalSize() const
virtual bool Plus(const double *x_ptr, const double *delta, double *x_plus_delta_ptr) const
GLM_FUNC_DECL genType cos(genType const &angle)
GLM_FUNC_DECL genType sin(genType const &angle)
virtual ~EigenQuaternionParameterization()
virtual bool ComputeJacobian(const double *x, double *jacobian) const