|
【c++】ObjectARX三点圆弧分段
static void DividArc( const AcGePoint3d& spt, const AcGePoint3d& ept, const AcGePoint3d& thirdPt,
int count, AcGePoint3dArray& pts )
{
pts.append( spt );
AcGeCircArc3d arc( spt, thirdPt, ept );
AcGePoint3d cnt = arc.center();
// double radius = arc.radius();
AcGeVector3d v1 = spt - cnt;
AcGeVector3d v2 = ept - cnt;
int c = ( arc.normal().z > 0 ? 1 : -1 ); // 弧线方向
double a1 = v1.angleTo( AcGeVector3d::kXAxis, -AcGeVector3d::kZAxis );
double a2 = v2.angleTo( AcGeVector3d::kXAxis, -AcGeVector3d::kZAxis );
double dq = abs( a2 - a1 ) / count;
//acutPrintf(_T("\na1:%.3f, a2:%.3f dq:%.3f c:%d"), a1, a2, dq, c);
for( int i = 1; i < count; i++ )
{
v1.rotateBy( c * dq, AcGeVector3d::kZAxis );
pts.append( cnt + v1 );
//acutPrintf(_T("\n点%d:(%d,%d)"),i,pts[i].x,pts[i].y);
}
pts.append( ept );
} |
|