[求助]怎样在ARX中实现旋转一个实体,如将一个矩形或一条直线旋转25度?
AcDbEntity实体旋转的一般方法
所有AcDbEntity类型的实体都通过调用transformBy()函数来实现诸如旋转、平移、比例缩放、复制等操作。你若需要在你的自定义实体(即从AcDbEntity类派生)中实现这些操作,就必须重载transformBy()函数。transformBy()函数的原型为:
virtual Acad::ErrorStatustransformBy(const AcGeMatrix3d& xform);
在这需要一个AcGeMatrix3d类型的参数。它是一个4X4矩阵,通过设置矩阵来实现各种操作。
以下代码是我个人理解,你试试。
AcGePoint3d origin(0,0,0);
AcGeVector3d e0(1,0,0);
AcGeVector3d e1(0,1,0);
AcGevector3d e2(0,0,1);
AcGeMatrix3d mat;
mat->setCoordSystem(origin,e0,e1,e2);//将mat设置与当前坐标系相关
Double ang;//旋转角度
AcGeVector3d axle;//旋转轴
AcGePoint3d cen; //旋转中心
...//初始化以上三个参数
mat->setToRatation(angle,axle,cen);//计算旋转变换矩阵
obj->transformBy(mat);//obj为要旋转的实体 <P>顶烙铁</P>
<P>顺便提问:leeyeafu上面的 </P>
<P>obj->transformBy(mat); //obj为要旋转的实体 </P>
<P>obj句柄怎么获得?</P>
<P>如果想旋转模型空间的整个实体,仍然是用这个方法吗,还是从view入手?</P>
页:
[1]