Alermath.hpp 367 B

12345678910111213141516171819202122
  1. #pragma once
  2. #define TOOFAST 1.f
  3. namespace math {
  4. template<typename T>
  5. inline int sgn(T t) {
  6. return t == 0 ? 0 : t > 0 ? 1 : -1;
  7. }
  8. inline float dist(sf::Vector2f p1, sf::Vector2f p2) {
  9. float dx = p1.x - p2.x;
  10. float dy = p1.y - p2.y;
  11. return std::sqrt(dx * dx + dy * dy);
  12. }
  13. inline float non_negative(float x) {
  14. return x >= 0.f ? x : 0.f;
  15. }
  16. }