【MSCE U13 C++】放置cell时,如何设置旋转矩阵使得cell的方向和鼠标一致?

老师,您好

       请问一下,我看我想实现如下视频所示的,放置cell时,cell的方向和鼠标的方向一致,该如何设置旋转矩阵?谢谢。

Parents Reply
  • 如下示例代码所示:

    void PlaceRoadCell(DPoint3dR ptOri, DPoint3dR ptTar)
    {
    	DPoint3d scale = { 1,1,1 }; 
    	DVec3d direction = DVec3d::FromStartEnd(ptOri, ptTar);
    	DVec3d z_axis = DVec3d::UnitZ();
    	DVec3d y_axis = DVec3d::FromCrossProduct(z_axis, direction);
    	DVec3d zz_axis = DVec3d::FromCrossProduct(direction, y_axis);
    	zz_axis.Normalize();
    	y_axis.Normalize();
    	direction.Normalize();
    	double scale_length = ptOri.Distance(ptTar) / ACTIVEMODEL->GetModelInfoCP()->GetUorPerMeter()/20;//20 is roarsign's length in the cell library
    	RotMatrix rMatrix = RotMatrix::FromColumnVectors(scale_length*direction, scale_length*y_axis, scale_length*zz_axis);
    	mdlCell_placeCell(&ptOri, &scale, false, &rMatrix, NULL, 0, false, 0, 0, L"RoadSign", NULL);
    }

    这是相应的单元库文件:

    Cell.dgn

    Answer Verified By: nian chen 

Children