MyMath.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. /**
  18. * Clamps the value between min and max, both inclusive.
  19. * @param min The minimum value
  20. * @param max The maximum value
  21. * @param value The value to clamp
  22. * @return The clamped value
  23. */
  24. static double Clamp(double min, double max, double value);
  25. /**
  26. * Linearly interpolates between a and b at value.
  27. * @param a The first value
  28. * @param b The second value
  29. * @param value The interpolation value
  30. * @return The interpolated value
  31. */
  32. static double Lerp(double a, double b, double value);
  33. /**
  34. * Inverse linearly interpolates between a and b at value.
  35. * @param a The first value
  36. * @param b The second value
  37. * @param value The value to get the interpolation of
  38. * @return The interpolation value
  39. */
  40. static double InverseLerp(double a, double b, double value);
  41. /**
  42. * Calculates the euclidean distance of the given points.
  43. * @param a The first point in 3D space
  44. * @param b The second point in 3D space
  45. * @return The euclidean distance
  46. */
  47. static double EuclideanDistance(cv::Point3d a, cv::Point3d b);
  48. };
  49. }
  50. #endif //GBMOT_UTILITY_H