Envelope: pin each side as the sum of its thrusters; drop the unused ManoeuvreEnvelope operator +; document Column(Thrust) against the allocator's Column(NominalThrust)
Builds not verified yet at this commit; verification follows on Yggdrasil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7437b13a5b
commit
ab80aa8f73
3 changed files with 38 additions and 8 deletions
|
|
@ -2089,8 +2089,9 @@ public struct FireControlDiagnostic
|
|||
}
|
||||
|
||||
// What a ship can do at this instant, in its own frame: acceleration along each body axis (m/s^2) and the kinematic
|
||||
// turn rate each way (rad/s; turning toward the ship's right is Clockwise). Each propulsor reports its share with
|
||||
// its own Execute arithmetic and Ship sums them; nothing stores it. Zero is the envelope of anything that is not a Ship.
|
||||
// turn rate each way (rad/s; turning toward the ship's right is Clockwise). Ship derives it each update as the box
|
||||
// extremes of its thrusters' columns (Ship.RecalculateEnvelope); nothing stores it. Zero is the envelope of anything
|
||||
// that is not a Ship.
|
||||
public readonly struct ManoeuvreEnvelope
|
||||
{
|
||||
public readonly float Forward, Reverse, Left, Right, Clockwise, CounterClockwise;
|
||||
|
|
@ -2104,10 +2105,6 @@ public readonly struct ManoeuvreEnvelope
|
|||
Clockwise = clockwise;
|
||||
CounterClockwise = counterClockwise;
|
||||
}
|
||||
|
||||
public static ManoeuvreEnvelope operator +(ManoeuvreEnvelope a, ManoeuvreEnvelope b) => new ManoeuvreEnvelope(
|
||||
a.Forward + b.Forward, a.Reverse + b.Reverse, a.Left + b.Left, a.Right + b.Right,
|
||||
a.Clockwise + b.Clockwise, a.CounterClockwise + b.CounterClockwise);
|
||||
}
|
||||
|
||||
// How unpredictably an entity is changing its motion, observed from its measured acceleration. The trend is an
|
||||
|
|
|
|||
|
|
@ -85,8 +85,10 @@ public class Ship : Entity
|
|||
#region ThrustCalculation
|
||||
|
||||
// What this ship can do at this instant (see ManoeuvreEnvelope): the box extremes of the thrusters' columns at their
|
||||
// live, granted thrust (zero when unpowered or not Active), the same columns the allocator solves with. Derived each
|
||||
// update, never saved.
|
||||
// live thrust (zero when unpowered or not Active), because it reports what the ship can do now. The allocator solves
|
||||
// with Column(NominalThrust), the full-grant column, because a column promises what a thruster does at a full grant
|
||||
// and the allocator must not reshape its answer as the grant moves. Same geometry (Thruster.Column), different thrust.
|
||||
// Derived each update, never saved.
|
||||
public ManoeuvreEnvelope Envelope { get; private set; }
|
||||
|
||||
private void RecalculateEnvelope()
|
||||
|
|
|
|||
|
|
@ -431,6 +431,37 @@ public sealed partial class RunStartTests
|
|||
Assert.True(djinni.Acceleration.x < -1f, "it still strafes left");
|
||||
}
|
||||
|
||||
// Each side of the envelope is the sum of what every thruster pushing that way contributes, never the largest one:
|
||||
// the Djinni has several thrusters on a side, so its Left and Right are the sums of the positive and negative
|
||||
// x of its live columns (Thruster.Column at live thrust, the owner of that geometry).
|
||||
[Fact]
|
||||
public void EachSideOfTheEnvelopeSumsTheThrustersPushingThatWay()
|
||||
{
|
||||
var (_, _, djinni) = EvFleet();
|
||||
EvSettle(djinni);
|
||||
foreach (var (move, look) in new[] { (float2(1, 0), float3(0, 0, 1)), (float2(-1, 0), float3(0, 0, 1)), (float2(0, 1), float3(0, 0, 1)),
|
||||
(float2(0, -1), float3(0, 0, 1)) })
|
||||
{
|
||||
djinni.MovementDirection = move;
|
||||
for (var step = 0; step < 20; step++)
|
||||
{
|
||||
EvFace(djinni, look);
|
||||
djinni.Update(EvDt);
|
||||
}
|
||||
}
|
||||
EvSettle(djinni);
|
||||
djinni.Update(EvDt);
|
||||
var columns = djinni.GetBehaviors<Thruster>().Where(t => t.Item.Active.Value).Select(t => t.Column(t.Thrust)).ToList();
|
||||
var rightPushers = columns.Where(c => c.x > 0f).ToList();
|
||||
var leftPushers = columns.Where(c => c.x < 0f).ToList();
|
||||
Assert.True(rightPushers.Count >= 2 && leftPushers.Count >= 2, "fixture: each side has more than one thruster");
|
||||
var right = rightPushers.Sum(c => c.x);
|
||||
var left = leftPushers.Sum(c => -c.x);
|
||||
Assert.True(right > 1.2f * rightPushers.Max(c => c.x) && left > 1.2f * leftPushers.Max(c => -c.x), "fixture: the sum exceeds the largest column");
|
||||
Assert.InRange(djinni.Envelope.Right, right * .99f, right * 1.01f);
|
||||
Assert.InRange(djinni.Envelope.Left, left * .99f, left * 1.01f);
|
||||
}
|
||||
|
||||
// The reach and the evasion read each side of the envelope for themselves: a forward-only ship that turns clockwise
|
||||
// fast and counter-clockwise slowly reaches further to its right than its left in the window, and its evasion
|
||||
// across a line of sight is the average of what it reaches to either side, capped by the spread it is observed to
|
||||
|
|
|
|||
Loading…
Reference in a new issue