- UID
- 3650
- 积分
- 134
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-4-6
- 最后登录
- 1970-1-1
|
发表于 2003-8-2 23:17:44
|
显示全部楼层
//多义线的圆弧插补数据输出
void arxtestccarc(AcDbPolyline *pPline,int num)
{
double cbulge;
ads_real len,rad,bu,angle1,L_angle,steplen,symbolK,symbolU,symbolV,deltaX,deltaY,distXY;
ads_point cpt1,cpt2,centerpt,intpt1,intpt2;//centerpt为圆心坐标,rad为半径,intpt为插补点
AcGePoint2d basept1,basept2;//点的类型转换
char cptbuffer[50];
pPline->getBulgeAt(0,cbulge);
// acutPrintf ("\nBulge.%f",bulge);
pPline->getPointAt(num,basept1);
pPline->getPointAt((num+1),basept2);
// pPline->close();
cpt1[X]=basept1.x;
cpt1[Y]=basept1.y;
cpt2[X]=basept2.x;
cpt2[Y]=basept2.y;
cpt1[Z]=cpt2[Z]=0;
len=acutDistance(cpt1,cpt2);
//acutPrintf ("\nlen.%f",len);
bu=fabs(cbulge);
//acutPrintf ("\nbu.%f",bu);
rad=(bu+1/bu)*len/4;
//acutPrintf ("\nrad.%f",rad);
angle1=acutAngle(cpt1,cpt2);
//acutPrintf ("\nangle1.%f",angle1);
//angle1=acutAngle(pt2,pt1);//试验pt1和pt2的次序影响
//acutPrintf ("\nangle2.%f",angle1);
L_angle=angle1+atan(1/(2*cbulge) - cbulge/2);
//acutPrintf ("\nL_angle.%f",L_angle);
centerpt[X]=cpt1[X]+rad*cos(L_angle);
centerpt[Y]=cpt1[Y]+rad*sin(L_angle);
//acutPrintf ("\ncenter:%f",centerpt[X]);
//acutPrintf ("\ncenter:%f",centerpt[Y]);
steplen=2*pow((2*rad*tolerance-tolerance*tolerance),0.5);
symbolK=steplen/rad;
symbolU=pow(symbolK,2)/2;
symbolV=symbolK*pow((1-symbolK*symbolK/4),0.5);
intpt1[X]=cpt1[X]-centerpt[X];//pt1x坐标平移
intpt1[Y]=cpt1[Y]-centerpt[Y];//pt1y坐标平移
intpt2[X]=cpt2[X]-centerpt[X];//pt2x坐标平移
intpt2[Y]=cpt2[Y]-centerpt[Y];//pt2y坐标平移
if(cbulge>0)//逆圆弧,在这里判断了,那么主程序中就无需判断了,只要分成是否等于零两类即可
{
//distXY=tolerance+1;//设置插补距离起始标志
for(distXY=steplen+1;distXY>steplen;) ////计算下一个点的循环程序,循环条件就是终点判断
{
deltaX=symbolU*intpt1[X]+symbolV*intpt1[Y];//求增量x
deltaY=symbolV*intpt1[X]-symbolU*intpt1[Y];//求增量y
intpt1[X]=intpt1[X]-deltaX;
intpt1[Y]=intpt1[Y]+deltaY;
distXY=acutDistance(intpt2,intpt1);//判断终点的计算
//将x坐标平移还原化成字符串
//将y坐标平移还原化成字符串
_ltoa((long)((intpt1[X]+centerpt[X])*39.37), cptbuffer,10 );//x
str=cptbuffer;
str="X"+str;
writedata(str,path);
_ltoa((long)((intpt1[Y]+centerpt[Y])*39.37), cptbuffer,10 );//y
str=cptbuffer;
str="Y"+str+"*";
writedata(str,path);
}
//写入pt2
}
if(cbulge<0)//顺圆弧
{
// distXY=tolerance+1;//设置插补距离起始标志
for(distXY=steplen+1;distXY>steplen;) ////计算下一个点的循环程序,循环条件就是终点判断
{
deltaX=symbolV*intpt1[Y]-symbolU*intpt1[X];//求增量x
deltaY=symbolV*intpt1[X]+symbolU*intpt1[Y];//求增量y
intpt1[X]=intpt1[X]+deltaX;
intpt1[Y]=intpt1[Y]-deltaY;
//判断终点的计算
distXY=acutDistance(intpt2,intpt1);
//将x坐标平移还原化成字符串
//将y坐标平移还原化成字符串
_ltoa((long)((intpt1[X]+centerpt[X])*39.37), cptbuffer,10 );//x
str=cptbuffer;
str="X"+str;
writedata(str,path);
_ltoa((long)((intpt1[Y]+centerpt[Y])*39.37), cptbuffer,10 );//y
str=cptbuffer;
str="Y"+str+"*";
writedata(str,path);
}
//写入pt2
}
// TODO: Implement the command
} |
|