NavisworksTransport/doc/working/2026-05-27-auto-object-rotation-implementation-plan.md
tian 7187bcf622 自动最优朝向: 黑盒实测模式
- 新增 ObjectPassageProjectionOptimizer(SO(3)粗搜索+Nelder-Mead)
- EditRotationWindow 加入"自动调整"按钮
- AnimationControlViewModel 实现黑盒实测评估(临时摆位→读BoundingBox→恢复)
- 设计文档和实现计划
2026-05-27 12:24:01 +08:00

2.4 KiB

Auto Object Rotation Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Add an automatic object rotation option that searches full 3D orientation space and minimizes passage cross-section projection area, preferring lower height when areas are close.

Architecture: Add a pure geometry optimizer under src/Utils/CoordinateSystem with deterministic candidate search and projection scoring. Wire it into EditRotationWindow through a small request/result context so the window stays reusable and writes the resulting host X/Y/Z correction into existing inputs.

Tech Stack: .NET Framework 4.8, C# 7.3, MSTest, System.Numerics.Quaternion.


Task 1: Geometry Optimizer

Files:

  • Create: src/Utils/CoordinateSystem/ObjectPassageProjectionOptimizer.cs

  • Test: UnitTests/CoordinateSystem/ObjectPassageProjectionOptimizerTests.cs

  • Modify: TransportPlugin.csproj

  • Modify: NavisworksTransport.UnitTests.csproj

  • Write failing tests for cross-section area scoring, height tie-break, deterministic output, and degenerate path directions.

  • Run ./run-unit-tests.bat and verify the new tests fail because the optimizer does not exist.

  • Implement deterministic full-3D candidate search using quaternion candidates from axis permutations and Euler refinement.

  • Run ./run-unit-tests.bat and verify the new tests pass.

Task 2: UI Context And Button

Files:

  • Modify: src/UI/WPF/Views/EditRotationWindow.xaml

  • Modify: src/UI/WPF/Views/EditRotationWindow.xaml.cs

  • Modify: src/UI/WPF/ViewModels/AnimationControlViewModel.cs

  • Add ObjectPassageProjectionOptimizationRequest construction in the ViewModel using current path start direction, object dimensions in model units, and HostCoordinateAdapter.

  • Add an “自动调整” button in the adjustment window.

  • On click, call the optimizer, update X/Y/Z text fields, and keep the dialog open for user review.

  • Show a clear warning without changing values when optimization input is invalid.

Task 3: Verification

Files:

  • No new files.

  • Run ./run-unit-tests.bat.

  • Run ./compile.bat.

  • Inspect git diff for unrelated changes and keep the change scoped.