fix: 修正 GiDrawUtility::RotateAndMove 旋转后的平移量 #63

Closed
home-laptop wants to merge 1 commits from home-lenovo-legion-r9000/fix/gidrawutility-rotateandmove AGit into main
pull from: home-lenovo-legion-r9000/fix/gidrawutility-rotateandmove
@@ -178,12 +178,20 @@ AECDLLIMPEXP AcGeMatrix3d GiDrawUtility::RotateAndMove(const AcGeVector3d &vtOri
{
AcGeVector3d _vtOrig(vtOrig);
AcGeVector3d _vtDist(vtDist);
_vtOrig *= 1;// 保证长度不为0
_vtDist *= 1;// 保证长度不为0
AcGeMatrix3d mat(AcGeMatrix3d::kIdentity);
//mat = _vtDist.rotateTo(_vtOrig);
mat = _vtOrig.rotateTo(_vtDist);
mat.setTranslation(ptDist - ptOrig);
// 零向量没有方向,rotateTo 结果未定义,回退到 Z 轴
if (_vtOrig.isZeroLength())
_vtOrig = AcGeVector3d::kZAxis;
if (_vtDist.isZeroLength())
_vtDist = AcGeVector3d::kZAxis;
AcGeMatrix3d mat(_vtOrig.rotateTo(_vtDist));
// 矩阵语义为 p' = R·p + t。要把 ptOrig 搬到 ptDist,平移量必须是
// ptDist - R·ptOrig;用 ptDist - ptOrig 只在 ptOrig 为原点时成立
AcGePoint3d ptRotated(ptOrig);
ptRotated.transformBy(mat);
mat.setTranslation(ptDist - ptRotated);
return mat;
}