AcGeCircArc2d
来源:互联网 发布:舞曲制作软件 编辑:程序博客网 时间:2024/06/05 19:25
AcGeCircArc2d类主要和圆弧数据信息的计算相关,在计算多段线凸度的使用较多.由于设计的比较灵活,并且其角度,参考向量以及方向的概念和常规有些不同,如果不小心,可能产生不少错误.
在CAD默认中,一般的角度概念定义如下:
X轴正向单位向量,按逆时针旋转到和某一向量重合的位置时经过的角度,即为该向量的角度.
但在AcGeCircArc2d中,"角度"的概念发生了变化--不再以X轴正向为基线,也不一定按照逆时针旋转.
在AcGeCircArc2d中,角度由参考向量和圆弧方向共同决定--圆弧上某一点的角度的概念为:
圆弧参考向量以圆心为基点,沿圆弧方向旋转到圆心到该点组成的向量的重合位置时所经过的角度,就是该点的角度.
下面以AcGeCircArc2d两个构造函数为例进行解释:
构造函数1
AcGeCircArc2d( const AcGePoint2d & ptCenter , double dRadius , double dAngleStart , double dAngleEnd , const AcGeVector2d& refVec = AcGeVector2d::kXAxis, Adesk::Boolean isClockWise = Adesk::kFalse )
这里需要注意的是最后两个参数--参考向量refVec以及圆弧方向isClockWise.
PS:A( 0 , 100 ) B( 100 , 0 ) ;
AcGeCircArc2d arc1( AcGePoint2d( 0,0 ) , 100.0 , 0.0 , PI / 2.0 , AcGeVector2d::kXAxis , Adesk::kFalse )
AcGePoint2d ptStart = arc1.startPoint() ;//ptStart == ( 100 , 0 )
AcGePoint2d ptEnd = arc1.endPoint() ;// ptEnd == ( 0 , 100 )
double dAngleStart = arc1.startAng() ;// dAngleStart = 0.0 ;
double dAngleEnd = arc1.endAng() ;// dAngleEnd = PI / 2.0 ;
对上述结果,应该没有太多的疑问.
AcGeCircArc2d arc2( AcGePoint2d( 0,0 ) , 100.0 , 0.0 , PI / 2.0 , AcGeVector2d::kYAxis , Adesk::kTrue )
AcGePoint2d ptStart = arc2.startPoint() ;//ptStart == ( 0,100)
AcGePoint2d ptEnd = arc2.endPoint() ;//ptEnd == ( 0 , 0 )
double dAngleStart = arc2.startAng() ; // dAngleStart = 0.0 ;
double dAngleEnd = arc2.endAng() ; // dAngleEnd = 0.0 ;
arc1和arc2不同之处就在于最后两个参数refVec和isClockWise.
arc2中,参考向量设为Y轴,圆弧方向设为正向,则其角度的计算方式就是--一Y轴正向为基线,沿顺时针方向旋转的角度.
因此其开始角度0.0所代表的点就是A点.结束角度PI / 2.0所代表的点就是B点.
构造函数2
AcGeCircArc2d( const AcGePoint2d & ptStart, const AcGePoint2d & ptCenter , const AcGePoint2d & ptEnd ) ;
对于该构造函数而言,其圆弧方向由三点的相对位置来决定,另一个重要的因素--参考向量则比较特殊.
AcGeCircArc2d arc3( AcGePoint2d( 100 , 0 ) , AcGePoint2d( 50√2 , 50√2 ) , AcGePoint2d( 0 , 100 ) ) ;AcGeCircArc2d arc4( AcGePoint2d( 0 , 100 ) , AcGePoint2d( 50√2 , 50√2 ) , AcGePoint2d( 100 , 0 ) ) ;
AcGePoint2d ptStart3 = arc3.startPoint() == ( 100,0 ) == B
AcGePoint2d ptEnd3 = arc3.endPoint() == ( 0 , 100 ) == A
double dAngleStart3 = arc3.startAng() == 0.0
double dAngleEnd3 = arc3.endAng() == PI / 2.0
AcGePoint2d ptStart4 = arc4.startPoint() == ( 0 , 100 ) == A
AcGePoint2d ptEnd4 = arc4.endPoint() == ( 100 , 0 ) == B
double dAngleStart4 = arc4.startAng() == 0.0
double dAngleEnd4 = arc4.endAng() == PI / 2.0
造成arc4求值角度异常的原因就在于该构造函数中隐含的参考向量.
构造函数2定义参考向量refVec为--圆心到起点.
因此arc3的参考向量为X轴,arc4的参考向量为Y轴.同时三点的相对位置也决定了--arc3圆弧沿逆时针旋转arc4沿顺时针旋转.
结合上述说明,就不难理解arc4求出的角度和坐标值了.
PS:AcGeCircArc2d一个重要的用途就是计算多段线的凸度,这里有一个较为通用的方法,可以忽略参考向量的干扰:
顺时针: 凸度 = tan( (开始角度-结束角度 ) / 4.0 ) ;
逆时针: 凸度 = tan( (结束角度 - 开始角度 ) / 4.0 ) ;