regionEllipse.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*****************************************************************
  2. Fichier : RegionEllipse.cpp
  3. Date : 03/01/11
  4. Version : 1.000
  5. Description : Classe de gestion des régions elliptiques
  6. |*****************************************************************/
  7. #include "regionEllipse.h"
  8. #include <cstdlib>
  9. RegionEllipse::RegionEllipse()
  10. {
  11. top = 0;
  12. bottom = 0;
  13. left = 0;
  14. right = 0;
  15. }
  16. RegionEllipse::~RegionEllipse()
  17. {
  18. }
  19. bool RegionEllipse::PtInRegion0(int x, int y)
  20. {
  21. Point vPoint;
  22. vPoint.x = x;
  23. vPoint.y = y;
  24. return PtInRegion(&vPoint);
  25. }
  26. bool RegionEllipse::PtInRegion(Point *vPoint)
  27. {
  28. double x, y, x0, y0, a, b;
  29. bool c = false;
  30. x0 = (left + right) / 2.0;
  31. y0 = (top + bottom) / 2.0;
  32. a = abs(right - left) / 2.0;
  33. b = abs(bottom - top) / 2.0;
  34. x = vPoint->x;
  35. y = vPoint->y;
  36. if (((((x - x0) / a) * ((x - x0) / a)) + (((y - y0) / b) * ((y - y0) / b))) <= 1)
  37. {
  38. c = true;
  39. }
  40. return c;
  41. }
  42. bool RegionEllipse::CreateEllipticRgn(Rect rcDraw)
  43. {
  44. top = rcDraw.top;
  45. bottom = rcDraw.bottom;
  46. left = rcDraw.left;
  47. right = rcDraw.right;
  48. return true;
  49. }
  50. void RegionEllipse::DeleteObject()
  51. {
  52. top = 0;
  53. bottom = 0;
  54. left = 0;
  55. right = 0;
  56. }