- 积分
- 150
- 明经币
- 个
- 注册时间
- 2003-4-20
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
通过一个4×4的矩阵对一条直线进行缩放和平移
代码如下:
void CWanDlg::OnButtonRelativeScale()
{
UpdateData(true);
IAcadLine Line;
IAcadModelSpace m_IMSpace;
SAFEARRAYBOUND RSbound;
RSbound.lLbound = 0;
RSbound.cElements = 4*4;
SAFEARRAY * pStartPoint = NULL;
pStartPoint= ::SafeArrayCreate(VT_R8,1,&RSbound);
if(!pStartPoint) AfxMessageBox("SafeArrayCreate error!");
double TransMatrix[4][4];
int index1,index2;
for(index1=0;index1<4;index1++)
{
for(index2=0;index2<4;index2++)
{
TransMatrix[index1][index2]=0;
}
}
TransMatrix[0][0]=m_RSFactor;//4*4矩阵的对角线上的变量
TransMatrix[1][1]=m_RSFactor;
TransMatrix[2][2]=m_RSFactor;
TransMatrix[3][3]=1;
long i=0;
for(index1=0;index1<4;index1++)
{
for(index2=0;index2<4;index2++)
{
SafeArrayPutElement(pStartPoint,&i,&TransMatrix[index1][index2]);
i++;
}//把数组赋值道SAFEARRAY里
}
VARIANT pRS;
VariantInit(&pRS);
pRS.vt =VT_ARRAY|VT_R8;
pRS.parray =pStartPoint;
int m_LineNum=m_IMSpace.GetCount();
VARIANT temp;
VariantInit(&temp);
temp.vt =VT_I2;
temp.iVal =m_LineNum-1;
Line=m_IMSpace.Item(temp);
Line.TransformBy(pRS);//转置 (这里出现了问题)
望各位大侠能帮小弟解决!!! |
|