27#ifndef G2O_STUFF_MISC_H
28#define G2O_STUFF_MISC_H
33#include "g2o/config.h"
48template <
class T1,
class T2,
class Pred = std::less<T1> >
51 const std::pair<T1, T2>& right) {
52 return Pred()(left.first, right.first);
60inline constexpr double cst(
long double v) {
return (
double)v; }
62constexpr double const_pi() {
return cst(3.14159265358979323846); }
76inline T hypot(T x, T y) {
77 return (T)(std::sqrt(x * x + y * y));
92 return degree *
cst(0.01745329251994329576);
98inline double rad2deg(
double rad) {
return rad *
cst(57.29577951308232087721); }
105 if (result <= 0.0)
return result +
const_pi();
122 x = std::cos(theta1) + std::cos(theta2);
123 y = std::sin(theta1) + std::sin(theta2);
124 if (x == 0 && y == 0)
127 return std::atan2(y, x);
159 T intervalWidth = u - l;
160 while (x < l) x += intervalWidth;
161 while (x > u) x -= intervalWidth;
168inline bool arrayHasNaN(
const double* array,
int size,
int* nanIndex = 0) {
169 for (
int i = 0; i < size; ++i)
171 if (nanIndex) *nanIndex = i;
void(* ForceLinkFunction)(void)
bool arrayHasNaN(const double *array, int size, int *nanIndex=0)
double average_angle(double theta1, double theta2)
double rad2deg(double rad)
constexpr double cst(long double v)
double deg2rad(double degree)
double inverse_theta(double th)
double normalize_theta(double theta)
constexpr double const_pi()
bool operator()(const std::pair< T1, T2 > &left, const std::pair< T1, T2 > &right)
ForceLinker(ForceLinkFunction function)