/*
double dx,dy : 圆心坐标
double radius : 半径
double angleStart : 起始点角度
double sweepAngle : 转过的角度
BOOL isUseDegree :标识angle是否为角度还是弧度
注:第一点到第二点按顺时针方向
*/
void ArcEx(HDC hDC,double dx,double dy, double radius,double angleStart,double sweepAngle,COLORREF color,BOOL isUseDegree)
{
double r = radius;//半径
double ts= angleStart;//起始角度
double te= angleStart + sweepAngle;//终止角度
double xc= dx;//圆心x
double yc= dy;//圆心y
CDC dc(hDC);
HPEN pen = ::CreatePen(PS_SOLID,2,color);
HPEN oldPen= dc.SelectPen(pen);
if(isUseDegree)//如果使用的是度数转化为弧度
{
ts = ts / 180 * PI;
te = te / 180 * PI;
}
//设置步进长度规则
double deg(0);
if( r < 5.08) deg = 0.015;
else if( r < 7.62) deg = 0.06;
else if( r < 25.4) deg = 0.075;
else deg = 0.015;
double dte = deg * 25.4 / r;
if(te<ts)//终止角<起始角
te+=PI*2;//PI = 3.1415;
int nCount=(int)((te-ts)/dte+0.5);
double ta=ts;
int x = xc+r*cos(ts);
int y = yc+r*sin(ts);
dc.MoveTo(x,y);
double ct(0),st(0);
for(int i=1;i<=nCount;i++)
{
ta+=dte;
ct=cos(ta);
st=sin(ta);
x=xc+r*ct;
y=yc+r*st;
dc.LineTo(x,y);
}
x = xc+r*cos(te);
y = yc+r*sin(te);
dc.LineTo(x,y);
dc.SelectPen(oldPen);
::DeleteObject(pen);
dc.Detach();
}