From d76660198e6ca5af5f765b592f2bed1eaad9d585 Mon Sep 17 00:00:00 2001 From: LittleGuo Date: Sun, 25 Oct 2026 18:10:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=20GiDrawUtility::Rota?= =?UTF-8?q?teAndMove=20=E6=97=8B=E8=BD=AC=E5=90=8E=E7=9A=84=E5=B9=B3?= =?UTF-8?q?=E7=A7=BB=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 平移项改为 ptDist - R·ptOrig:原 ptDist - ptOrig 仅在 ptOrig 为原点时成立;DrawTydf 的 bIsTfdy 分支 ptOrig 被移到 (0,0,H),vtMove 非 Z 轴时落点偏移 - 零向量输入回退 Z 轴:原 *_vtOrig *= 1 是 no-op,零向量 rotateTo 结果未定义 --- .../Code2026/AecRxBase/GiDrawUtility.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp b/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp index bd5121b..b12ebb5 100644 --- a/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp +++ b/SourceCode/Code2026/AecRxBase/GiDrawUtility.cpp @@ -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; } -- 2.54.0