求一圆的外切正方形的四个顶点坐标。
// cad x轴正方向为零度方向,逆时针为正
// centerPt为圆心坐标,radius为圆的半径,angle为正方形的第一个点的偏移角度
AcGePoint3dArray GetCalculateVertexZfx(const AcGePoint3d& centerPt, double radius,double angle)
{
AcGePoint3d ptA;
ptA.x = centerPt.x + radius*sqrt((double)2) * cos(angle);
ptA.y = centerPt.y + radius*sqrt((double)2) * sin(angle);
ptA.z = centerPt.z;
AcGeVector3d vec(centerPt.x-ptA.x, centerPt.y-ptA.y, 0);
单位向量
AcGeVector3d unitVec = vec.normalize();
绕Z轴旋转
// 以单位向量为基准,先偏移至最近计算的边
// 求出一条边后,继续偏移,计算另一条
unitVec.rotateBy( 45*PI/180, AcGeVector3d::kZAxis);
B点坐标 = A点坐标 + AB间的向量
AcGePoint3d ptB;
ptB = ptA + unitVec*2*radius;
//C点坐标是和A点对称的,可以通过圆心算
AcGePoint3d ptC;
ptC.x = centerPt.x - radius*sqrt((double)2) * cos(angle);
ptC.y = centerPt.y - radius*sqrt((double)2) * sin(angle);
ptC.z = centerPt.z;
//D点坐标可以通过向量 AB来旋转计算
AcG