common.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 & center, vec2 const & point, radian r);
  11. dim2::quad rotate(vec2 const & center, dim2::quad const & q, radian r);
  12. bool contains(dim2::line const & shape, dim2::point const & pt);
  13. bool contains(dim2::circle const & shape, dim2::point const & pt);
  14. bool contains(dim2::quad const & shape, dim2::point const & pt);
  15. bool intersects(dim2::line const & lhs, dim2::line const & rhs);
  16. bool intersects(dim2::line const & lhs, dim2::circle const & rhs);
  17. bool intersects(dim2::line const & lhs, dim2::quad const & rhs);
  18. bool intersects(dim2::quad const & lhs, dim2::line const & rhs);
  19. bool intersects(dim2::quad const & lhs, dim2::circle const & rhs);
  20. bool intersects(dim2::quad const & lhs, dim2::quad const & rhs);
  21. bool intersects(dim2::circle const & lhs, dim2::line const & rhs);
  22. bool intersects(dim2::circle const & lhs, dim2::quad const & rhs);
  23. bool intersects(dim2::circle const & lhs, dim2::circle const & rhs);
  24. }
  25. namespace math {
  26. inline bool intersects(dim2::quad const & lhs, dim2::line const & rhs) {
  27. return intersects(rhs, lhs);
  28. }
  29. inline bool intersects(dim2::circle const & lhs, dim2::line const & rhs) {
  30. return intersects(rhs, lhs);
  31. }
  32. inline bool intersects(dim2::circle const & lhs, dim2::quad const & rhs) {
  33. return intersects(rhs, lhs);
  34. }
  35. }