17 #ifndef CARTOGRAPHER_COMMON_MATH_H_ 18 #define CARTOGRAPHER_COMMON_MATH_H_ 25 #include "ceres/ceres.h" 32 T
Clamp(
const T value,
const T min,
const T max) {
44 constexpr T
Power(T base,
int exponent) {
45 return (exponent != 0) ? base *
Power(base, exponent - 1) : T(1);
55 constexpr
double DegToRad(
double deg) {
return M_PI * deg / 180.; }
58 constexpr
double RadToDeg(
double rad) {
return 180. * rad / M_PI; }
63 const T kPi = T(M_PI);
64 while (difference > kPi) difference -= 2. * kPi;
65 while (difference < -kPi) difference += 2. * kPi;
70 T
atan2(
const Eigen::Matrix<T, 2, 1>& vector) {
77 zw[0] = z[0] * w[0] - z[1] * w[1] - z[2] * w[2] - z[3] * w[3];
78 zw[1] = z[0] * w[1] + z[1] * w[0] + z[2] * w[3] - z[3] * w[2];
79 zw[2] = z[0] * w[2] - z[1] * w[3] + z[2] * w[0] + z[3] * w[1];
80 zw[3] = z[0] * w[3] + z[1] * w[2] - z[2] * w[1] + z[3] * w[0];
86 #endif // CARTOGRAPHER_COMMON_MATH_H_
T atan2(const Eigen::Matrix< T, 2, 1 > &vector)
constexpr double RadToDeg(double rad)
constexpr T Power(T base, int exponent)
void QuaternionProduct(const double *const z, const T *const w, T *const zw)
constexpr double DegToRad(double deg)
T Clamp(const T value, const T min, const T max)
T NormalizeAngleDifference(T difference)