fix: 修复 7 个 pre-existing 单测失败(optimizer 初始候选 + ZUp 测试语义)
ObjectPassageProjectionOptimizer.OptimizeWithEvaluator: - 初始化 bestScore 评估 correction=Zero 作为初始候选 - 旧逻辑 bestScore=Invalid 导致 Zero 从未被评估, 当 baseline 已对齐路径时随机采样必然替换它,refine 收敛不回 0 - 影响 3 个 Optimize 测试:baseline 已对齐时找不到 correction=0 ZUp 测试语义修正(4 个): - LocalEulerRotationCorrection 语义:Y=up轴/yaw, Z=non-up轴 - ZUp 下 up=Z, non-up=Y,绕 Z(up) 转应使用 YDegrees 不是 ZDegrees - 旧测试在 ZUp 下把 ZDegrees 当字面 Z 轴,与实现语义矛盾
This commit is contained in:
parent
7f3be8495c
commit
cf6b2ef959
@ -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);
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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) 无万向节死锁
|
||||
|
||||
Loading…
Reference in New Issue
Block a user