| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /*****************************************************************
- Fichier : RegionEllipse.cpp
- Date : 03/01/11
- Version : 1.000
- Description : Classe de gestion des régions elliptiques
- |*****************************************************************/
- #include "regionEllipse.h"
- #include <cstdlib>
- RegionEllipse::RegionEllipse()
- {
- top = 0;
- bottom = 0;
- left = 0;
- right = 0;
- }
- RegionEllipse::~RegionEllipse()
- {
- }
- bool RegionEllipse::PtInRegion0(int x, int y)
- {
- Point vPoint;
- vPoint.x = x;
- vPoint.y = y;
- return PtInRegion(&vPoint);
- }
- bool RegionEllipse::PtInRegion(Point *vPoint)
- {
- double x, y, x0, y0, a, b;
- bool c = false;
-
- x0 = (left + right) / 2.0;
- y0 = (top + bottom) / 2.0;
-
- a = abs(right - left) / 2.0;
- b = abs(bottom - top) / 2.0;
-
- x = vPoint->x;
- y = vPoint->y;
- if (((((x - x0) / a) * ((x - x0) / a)) + (((y - y0) / b) * ((y - y0) / b))) <= 1)
- {
- c = true;
- }
-
- return c;
- }
- bool RegionEllipse::CreateEllipticRgn(Rect rcDraw)
- {
- top = rcDraw.top;
- bottom = rcDraw.bottom;
- left = rcDraw.left;
- right = rcDraw.right;
-
- return true;
- }
- void RegionEllipse::DeleteObject()
- {
- top = 0;
- bottom = 0;
- left = 0;
- right = 0;
- }
|