common.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // common.hpp
  3. // math
  4. //
  5. // Created by Sam Jaffe on 8/20/16.
  6. //
  7. #pragma once
  8. #include "math_fwd.hpp"
  9. namespace math {
  10. vec2 rotate(vec2 const & point, radian r);
  11. vec2 rotate(vec2 const & center, vec2 const & point, radian r);
  12. dim2::quad rotate(vec2 const & center, dim2::quad const & q, radian r);
  13. bool contains(dim2::line const & shape, dim2::point const & pt);
  14. bool contains(dim2::circle const & shape, dim2::point const & pt);
  15. bool contains(dim2::quad const & shape, dim2::point const & pt);
  16. bool intersects(dim2::line const & lhs, dim2::line const & rhs);
  17. bool intersects(dim2::line const & lhs, dim2::circle const & rhs);
  18. bool intersects(dim2::line const & lhs, dim2::quad const & rhs);
  19. bool intersects(dim2::quad const & lhs, dim2::line const & rhs);
  20. bool intersects(dim2::quad const & lhs, dim2::circle const & rhs);
  21. bool intersects(dim2::quad const & lhs, dim2::quad const & rhs);
  22. bool intersects(dim2::circle const & lhs, dim2::line const & rhs);
  23. bool intersects(dim2::circle const & lhs, dim2::quad const & rhs);
  24. bool intersects(dim2::circle const & lhs, dim2::circle const & rhs);
  25. }
  26. namespace math {
  27. inline bool intersects(dim2::quad const & lhs, dim2::line const & rhs) {
  28. return intersects(rhs, lhs);
  29. }
  30. inline bool intersects(dim2::circle const & lhs, dim2::line const & rhs) {
  31. return intersects(rhs, lhs);
  32. }
  33. inline bool intersects(dim2::circle const & lhs, dim2::quad const & rhs) {
  34. return intersects(rhs, lhs);
  35. }
  36. }