Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

87 lines
1.6 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TPGeEllipse.cpp
// = Version : ver2.0
// = Author : wlw
// = CreateDate : 2002-09-09
// = Description: 类的定义
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#include "StdAfx.h"
#include "TPGeEllipse.h"
TPGeEllipse::TPGeEllipse()
{
}
TPGeEllipse::TPGeEllipse(const TGPoint&pt,double aRadius,double bRadius):center(pt),a(aRadius),b(bRadius)
{
}
TPGeEllipse::~TPGeEllipse()
{
}
bool TPGeEllipse::IsValid() const
{
return UP_ZEROD(a) && UP_ZEROD(b);
}
bool TPGeEllipse::IsCircle() const
{
double temp = a - b;
return EQUAL_ZEROD(temp);
}
void TPGeEllipse::Pt2Pa(const TGPoint&pt,double&pa) const
{
pa = TGVector2D(center,pt).GetAngle();
}
void TPGeEllipse::Pa2Pt(double pa,TGPoint&pt) const
{
pt.x = center.x + a * cos(pa);
pt.y = center.y + b * sin(pa);
pt.z = center.z;
}
bool TPGeEllipse::operator != (const TPGeEllipse&e) const
{
return !(*this == e);
}
GRelation TPGeEllipse::HitTest(const TGPoint&pt) const
{
double dx = pt.x - center.x, dy = pt.y - center.y;
double temp = dx * dx / (a * a) + dy * dy / (b * b) - 1;
if(UP_ZERO(temp))
{
return GR_OUTSIDE;
}
else if(DOWN_ZERO(temp))
{
return GR_INSIDE;
}
else
{
return GR_IN;
}
}
bool TPGeEllipse::operator == (const TPGeEllipse&e) const
{
double d = a - e.a;
if(EQUAL_ZEROD(d))
{
d = b - e.b;
if(EQUAL_ZEROD(d))
{
return center == e.center;
}
}
return false;
}