From 5a6e81db7589b7417df314d6cd97d3dfa3a0a19b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 10 Oct 2026 20:23:27 +0200 Subject: [PATCH] wip reach probe --- .../Aetheria.Shared.Tests/EvasionTermTests.cs | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/EvasionTermTests.cs b/tests/Aetheria.Shared.Tests/EvasionTermTests.cs index a399f6ce9..009c55667 100644 --- a/tests/Aetheria.Shared.Tests/EvasionTermTests.cs +++ b/tests/Aetheria.Shared.Tests/EvasionTermTests.cs @@ -243,10 +243,29 @@ public sealed partial class RunStartTests return ((right + left) / 2, (forward + back) / 2); } - private static (float noseOn, float broadside) EvReach(Ship ship, float window) + // What the allocator can hold the heading and still push, per half-axis, from the live columns the ship allocates + // with: the allocator's net push for a full-stick intent on each axis with no turn asked. The turn limits stay the + // envelope's. + private static ManoeuvreEnvelope EvAllocatedEnvelope(Ship ship) + { + var columns = ship.GetBehaviors().Select(t => t.Column(t.NominalThrust)).ToArray(); + var throttles = new float[columns.Length]; + float Push(float2 move, float2 axis) + { + new ThrustAllocator().Allocate(columns, move, 0f, throttles); + var net = float2(0, 0); + for (var i = 0; i < columns.Length; i++) net += columns[i].xy * throttles[i]; + return dot(net, axis); + } + var e = ship.Envelope; + return new ManoeuvreEnvelope(Push(float2(0, 1), float2(0, 1)), Push(float2(0, -1), float2(0, -1)), + Push(float2(-1, 0), float2(-1, 0)), Push(float2(1, 0), float2(1, 0)), e.Clockwise, e.CounterClockwise); + } + + private static (float noseOn, float broadside) EvReach(Ship ship, float window, ManoeuvreEnvelope envelope) { var heading = float2(0, 1); - float Half(float2 n) => .5f * (FireControl.Reach(ship.Envelope, heading, n, window) + FireControl.Reach(ship.Envelope, heading, -n, window)); + float Half(float2 n) => .5f * (FireControl.Reach(envelope, heading, n, window) + FireControl.Reach(envelope, heading, -n, window)); return (Half(float2(1, 0)), Half(float2(0, 1))); } @@ -261,7 +280,9 @@ public sealed partial class RunStartTests var measured = EvMeasuredHalfWidths(ship, window); EvSettle(ship); ship.Update(EvDt); - var reach = EvReach(ship, window); + var reach = EvReach(ship, window, ship.Envelope); + var allocated = EvReach(ship, window, EvAllocatedEnvelope(ship)); + Console.WriteLine($"ALLOC {name}: allocated nose-on {allocated.noseOn:F3} broadside {allocated.broadside:F3}"); Console.WriteLine($"REACH {name}: nose-on reach {reach.noseOn:F3} measured {measured.noseOn:F3}; broadside reach {reach.broadside:F3} measured {measured.broadside:F3}"); results.Add((name, reach, measured)); }