MyMath.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // Created by wrede on 02.05.16.
  3. //
  4. #ifndef GBMOT_UTILITY_H
  5. #define GBMOT_UTILITY_H
  6. #include <cstdlib>
  7. #include <cmath>
  8. #include <opencv2/core/core.hpp>
  9. namespace util
  10. {
  11. /**
  12. * Utility class for mathematical operations.
  13. */
  14. class MyMath
  15. {
  16. public:
  17. static const double PI;
  18. /**
  19. * Clamps the value between min and max, both inclusive.
  20. * @param min The minimum value
  21. * @param max The maximum value
  22. * @param value The value to clamp
  23. * @return The clamped value
  24. */
  25. static double Clamp(double min, double max, double value);
  26. /**
  27. * Linearly interpolates between a and b at value.
  28. * @param a The first value
  29. * @param b The second value
  30. * @param value The interpolation value
  31. * @return The interpolated value
  32. */
  33. static double Lerp(double a, double b, double value);
  34. /**
  35. * Inverse linearly interpolates between a and b at value.
  36. * @param a The first value
  37. * @param b The second value
  38. * @param value The value to get the interpolation of
  39. * @return The interpolation value
  40. */
  41. static double InverseLerp(double a, double b, double value);
  42. /**
  43. * Calculates the euclidean distance of the given points.
  44. * @param a The first point in 3D space
  45. * @param b The second point in 3D space
  46. * @return The euclidean distance
  47. */
  48. static double EuclideanDistance(cv::Point3d a, cv::Point3d b);
  49. /**
  50. * Calculates the euclidean distance of the given points.
  51. * @param a The first point in 2D space
  52. * @param b The second point in 2D space
  53. * @return The euclidean distance
  54. */
  55. static double EuclideanDistance(cv::Point2d a, cv::Point2d b);
  56. /**
  57. * Calculates the radian value of the given degree value.
  58. * @param degree The arc value in degree
  59. * @return The arc value in radian
  60. */
  61. static double Radian(double degree);
  62. };
  63. }
  64. #endif //GBMOT_UTILITY_H