point_in_circle.h 733 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef IGL_POINT_IN_CIRCLE
  2. #define IGL_POINT_IN_CIRCLE
  3. namespace igl
  4. {
  5. // Determine if 2d point is in a circle
  6. // Inputs:
  7. // qx x-coordinate of query point
  8. // qy y-coordinate of query point
  9. // cx x-coordinate of circle center
  10. // cy y-coordinate of circle center
  11. // r radius of circle
  12. // Returns true if query point is in circle, false otherwise
  13. inline bool point_in_circle(
  14. const double qx,
  15. const double qy,
  16. const double cx,
  17. const double cy,
  18. const double r);
  19. }
  20. // Implementation
  21. inline bool igl::point_in_circle(
  22. const double qx,
  23. const double qy,
  24. const double cx,
  25. const double cy,
  26. const double r)
  27. {
  28. return (qx-cx)*(qx-cx) + (qy-cy)*(qy-cy) - r*r < 0;
  29. }
  30. #endif