objectarx向量的用法

求一圆的外切三角形的三个顶点坐标。

 // cad x轴正方向为零度方向,逆时针为正

// centerPt为圆心坐标,radius为圆的半径,angle为三角形顶角偏移角度

 AcGePoint3dArray CustemEntity::GetCalculateVertexCoordinate(const AcGePoint3d& centerPt,double radius,double angle)
 {
AcGePoint3d calculatePt;


calculatePt.x = centerPt.x+2*radius*cos(angle);


calculatePt.y = centerPt.y+2*radius*sin(angle);


calculatePt.z = centerPt.z;


AcGeVector3d vec(centerPt.x-calculatePt.x,centerPt.y-calculatePt.y,0);
  // 单位向量
AcGeVector3d unitVec = vec.normalize() ;


AcGePoint3d calculatePt2;
// 绕Z轴旋转
// 以单位向量为基准,先偏移至最近计算的边
// 求出一条边后,继续偏移,计算另一条
unitVec.rotateBy(30*PI/180, AcGeVector3d::kZAxis);
  //AB间的向量=A~B点距离 * AB间的向量的单位向量 
calculatePt2 = calculatePt + unitVec*sqrt((double)3)*2*radius;


AcGePoint3d calculatePt3;


unitVec.rotateBy(300*PI/180, AcGeVector3d::kZAxis);


calculatePt3 = calculatePt +unitVec*sqrt((double)3)*2*radius ;


AcGePoint3dArray array;


array.append(calculatePt);


array.append(calculatePt2);


array.append(calculatePt3);


return array;




 }

你可能感兴趣的:(objectArx)