diff --git a/UnitTests/CoordinateSystem/HostCoordinateAdapterTests.cs b/UnitTests/CoordinateSystem/HostCoordinateAdapterTests.cs index a5d7931..84496f3 100644 --- a/UnitTests/CoordinateSystem/HostCoordinateAdapterTests.cs +++ b/UnitTests/CoordinateSystem/HostCoordinateAdapterTests.cs @@ -213,25 +213,27 @@ namespace NavisworksTransport.UnitTests.CoordinateSystem } [TestMethod] - public void ZUp_HostRotationCorrection_ShouldKeepHostZAxisInvariantInHostSpace() + public void ZUp_HostRotationCorrection_YDegrees_ShouldKeepHostZAxisInvariant() { + // ZUp 下 YDegrees = up 轴(=Z)。绕 Z 转,Z 轴自身不变。 var adapter = new HostCoordinateAdapter(CoordinateSystemType.ZUp); Quaternion hostCorrection = adapter.CreateHostRotationCorrection( - new LocalEulerRotationCorrection(0.0, 0.0, 90.0)); + new LocalEulerRotationCorrection(0.0, 90.0, 0.0)); Vector3 rotatedUp = Vector3.Transform(Vector3.UnitZ, hostCorrection); AssertVector(rotatedUp, 0.0, 0.0, 1.0); } [TestMethod] - public void ZUp_ComposeHostQuaternion_ShouldApplyHostZCorrectionAfterBaseline() + public void ZUp_ComposeHostQuaternion_YDegrees_ShouldApplyHostZAxisRotation() { + // ZUp 下 YDegrees = up 轴(=Z)。绕 Z 转 90°:X→Y, Y→-X, Z 不变。 var adapter = new HostCoordinateAdapter(CoordinateSystemType.ZUp); var baseline = Quaternion.Identity; Quaternion composed = adapter.ComposeHostQuaternion( baseline, - new LocalEulerRotationCorrection(0.0, 0.0, 90.0)); + new LocalEulerRotationCorrection(0.0, 90.0, 0.0)); Matrix4x4 linear = Matrix4x4.CreateFromQuaternion(composed); diff --git a/UnitTests/CoordinateSystem/RotatedObjectExtentHelperTests.cs b/UnitTests/CoordinateSystem/RotatedObjectExtentHelperTests.cs index ca93b9b..42e15b2 100644 --- a/UnitTests/CoordinateSystem/RotatedObjectExtentHelperTests.cs +++ b/UnitTests/CoordinateSystem/RotatedObjectExtentHelperTests.cs @@ -49,12 +49,14 @@ namespace NavisworksTransport.UnitTests.CoordinateSystem } [TestMethod] - public void ZUp_HostY90_ShouldPromoteForwardSizeToUpExtent() + public void ZUp_HostZDegrees_ShouldPromoteForwardSizeToUpExtent() { + // ZUp 下 ZDegrees = non-up 轴(=Y)。绕 Y 转 90°:X(forward)→-Z(up), Z(up)→X。 + // forward(6) 提升到 up,up(2) 降到 forward。 var adapter = new HostCoordinateAdapter(CoordinateSystemType.ZUp); var convention = ModelAxisConvention.CreateDefaultForHost(CoordinateSystemType.ZUp); Quaternion correction = adapter.CreateCanonicalRotationCorrection( - new LocalEulerRotationCorrection(0.0, 90.0, 0.0)); + new LocalEulerRotationCorrection(0.0, 0.0, 90.0)); var result = RotatedObjectExtentHelper.CalculateProjectedSemanticExtents( convention, @@ -69,12 +71,14 @@ namespace NavisworksTransport.UnitTests.CoordinateSystem } [TestMethod] - public void ZUp_HostZ90_ShouldKeepUpExtentUnchanged() + public void ZUp_HostYDegrees_ShouldKeepUpExtentUnchanged() { + // ZUp 下 YDegrees = up 轴(=Z)。绕 Z 转 90°:X→Y, Y→-X, Z(up) 不变。 + // forward 和 side 互换,up 不变。 var adapter = new HostCoordinateAdapter(CoordinateSystemType.ZUp); var convention = ModelAxisConvention.CreateDefaultForHost(CoordinateSystemType.ZUp); Quaternion correction = adapter.CreateCanonicalRotationCorrection( - new LocalEulerRotationCorrection(0.0, 0.0, 90.0)); + new LocalEulerRotationCorrection(0.0, 90.0, 0.0)); var result = RotatedObjectExtentHelper.CalculateProjectedSemanticExtents( convention, diff --git a/src/Utils/CoordinateSystem/ObjectPassageProjectionOptimizer.cs b/src/Utils/CoordinateSystem/ObjectPassageProjectionOptimizer.cs index aaba055..29acaee 100644 --- a/src/Utils/CoordinateSystem/ObjectPassageProjectionOptimizer.cs +++ b/src/Utils/CoordinateSystem/ObjectPassageProjectionOptimizer.cs @@ -157,7 +157,9 @@ namespace NavisworksTransport.Utils.CoordinateSystem } LocalEulerRotationCorrection bestCorrection = LocalEulerRotationCorrection.Zero; - ObjectPassageProjectionScore bestScore = ObjectPassageProjectionScore.Invalid; + // 必须评估 correction=Zero 作为初始候选:当 baseline 已对齐路径时, + // Zero 就是最优解;若不评估,随机采样必然替换它,refine 也收敛不回 0。 + ObjectPassageProjectionScore bestScore = evaluator(bestCorrection); Quaternion bestQuaternion = Quaternion.Identity; // S³ 均匀采样四元数 → 转 Euler → 覆盖 SO(3) 无万向节死锁