Well-law tests follow the subzone law: two suns 600 apart are two subzones, not a superposition
WellsSuperpose is removed (its rule, roots superpose everywhere, is the one multi-root-zone-shape decides); HeightIsThePotentialOverOneK and FlowFieldTests probe inside each well's reach. ZoneWorlds gains Belt and AsteroidSize; fade and ring tolerances are relative to the Plummer pull. Not yet run on dotnet at this commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
250b61be2c
commit
65aa61811e
4 changed files with 22 additions and 33 deletions
|
|
@ -124,8 +124,8 @@ public sealed class FlowFieldTests : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
// Zone.Flow's slope term reads the owner's superposed force, not any one body's: two equal wells, probes off the
|
||||
// axis between them where the nearest body's direction and the sum's differ.
|
||||
// Zone.Flow's slope term reads the owner's force at the point: two equal wells 600 apart (two subzones, each felt within
|
||||
// its reach of 300), probes inside each off the axis, where the direction is not along the axis.
|
||||
[Fact]
|
||||
public void TheSlopeTermFollowsTheSuperposedForce()
|
||||
{
|
||||
|
|
@ -135,7 +135,7 @@ public sealed class FlowFieldTests : IDisposable
|
|||
WellFixture.Dig(_items.ItemData, pack, planets, 300f, 100f, new float2(300f, 0f));
|
||||
var zone = new Zone(_items, planets, pack, new GalaxyZone { Name = "Two Wells", Owner = null }, null);
|
||||
var checkedPoints = 0;
|
||||
foreach (var at in new[] { float2(100f, 400f), float2(-50f, -300f), float2(250f, 220f), float2(-420f, 90f) })
|
||||
foreach (var at in new[] { float2(-200f, 150f), float2(-350f, -120f), float2(250f, 220f), float2(420f, -90f) })
|
||||
{
|
||||
var flow = zone.Flow(float3(at.x, 3f, at.y));
|
||||
var expected = 1.5f * normalize(zone.GetForce(at));
|
||||
|
|
|
|||
|
|
@ -262,29 +262,6 @@ public sealed class PotentialOwnerTests : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WellsSuperpose()
|
||||
{
|
||||
var planets = Curves();
|
||||
var a = (mass: 29.2f, at: new float2(-300f, 0f));
|
||||
var b = (mass: 14152.4f, at: new float2(300f, 0f));
|
||||
var both = ZoneOf(planets, a, b);
|
||||
var onlyA = ZoneOf(planets, a);
|
||||
var onlyB = ZoneOf(planets, b);
|
||||
var probes = new[]
|
||||
{
|
||||
float2(-300f, 0f), float2(300f, 0f), float2(-310f, 4f), float2(305f, -9f), float2(0f, 0f), float2(0f, 250f),
|
||||
float2(-150f, 100f), float2(150f, -100f), float2(900f, 700f), float2(-1200f, -300f), float2(40f, 3000f), float2(-300f, -40f)
|
||||
};
|
||||
foreach (var p in probes)
|
||||
{
|
||||
var sum = onlyA.GetForce(p) + onlyB.GetForce(p);
|
||||
Near(sum.x, both.GetForce(p).x, 1e-4f);
|
||||
Near(sum.y, both.GetForce(p).y, 1e-4f);
|
||||
Near(onlyA.GetHeight(p) + onlyB.GetHeight(p), both.GetHeight(p), 1e-4f);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HeightIsThePotentialOverOneK()
|
||||
{
|
||||
|
|
@ -309,11 +286,20 @@ public sealed class PotentialOwnerTests : IDisposable
|
|||
float2(-300f + .5f * core0, 0f), float2(-300f, .65f * core0), float2(-300f - .86f * core0, 0f), float2(-300f + .6f * core0, .6f * core0),
|
||||
float2(300f + .55f * core1, 0f), float2(300f, -.7f * core1), float2(300f - .86f * core1, 0f), float2(300f + .9f * core1, 0f)
|
||||
};
|
||||
foreach (var p in inCore.Concat(new[] { float2(-200f, 120f), float2(0f, 0f), float2(100f, -300f), float2(500f, 40f), float2(-290f, 12f), float2(310f, 20f), float2(700f, 700f), float2(-80f, -500f) }))
|
||||
// Two suns 600 apart are two subzones: each is felt only inside its own reach (half the distance, 300), so the height
|
||||
// there is that well's alone (plus the zone node's constant, which differences cancel) and the force is its alone.
|
||||
var w0 = float2(-300f, 0f);
|
||||
var w1 = float2(300f, 0f);
|
||||
foreach (var p in inCore.Concat(new[] { float2(-200f, 120f), float2(100f, -300f), float2(500f, 40f), float2(-290f, 12f), float2(310f, 20f), float2(700f, 700f), float2(-80f, -500f) }))
|
||||
{
|
||||
var expected = Phi(c0, core0, length(p - float2(-300f, 0f))) - Phi(c0, core0, PackRadius)
|
||||
+ Phi(c1, core1, length(p - float2(300f, 0f))) - Phi(c1, core1, PackRadius);
|
||||
Near(expected, two.GetHeight(p) * k, 1e-3f);
|
||||
var near0 = length(p - w0) < 250f;
|
||||
var near1 = length(p - w1) < 250f;
|
||||
if (near0 || near1)
|
||||
{
|
||||
var (at, wc, wcore) = near0 ? (w0, c0, core0) : (w1, c1, core1);
|
||||
var expected = Phi(wc, wcore, length(p - at)) - Phi(wc, wcore, 0f);
|
||||
Near(expected, (two.GetHeight(p) - two.GetHeight(at)) * k, 1e-3f);
|
||||
}
|
||||
|
||||
// The downhill slope of the potential is the force: the central difference of height * K is -GetForce.
|
||||
var gradient = float2(
|
||||
|
|
|
|||
|
|
@ -336,7 +336,8 @@ public sealed class WellLawTests : IDisposable
|
|||
{
|
||||
var t = (r * r - 225.0 * 225) / (337.5 * 337.5 - 225.0 * 225);
|
||||
var expected = Plummer(curves, 101f, r) * (1 - S(t));
|
||||
Assert.InRange(zone.Wells.PullAround(planet, r, moon), expected * (1 - 1e-5) - 1e-9, expected * (1 + 1e-5) + 1e-9);
|
||||
var scale = Plummer(curves, 101f, r); // float rounding of the four cancelling terms is relative to the Plummer pull
|
||||
Assert.InRange(zone.Wells.PullAround(planet, r, moon), expected - 1e-5 * scale, expected + 1e-5 * scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -358,7 +359,8 @@ public sealed class WellLawTests : IDisposable
|
|||
{
|
||||
var t = (r * r - 300.0 * 300) / (1500.0 * 1500 - 300.0 * 300);
|
||||
var expected = Plummer(curves, 140f, r) * S(t);
|
||||
Assert.InRange(zone.Wells.PullAround(node, r, default), expected * (1 - 1e-5) - 1e-9, expected * (1 + 1e-5) + 1e-9);
|
||||
var scale = Plummer(curves, 140f, r); // float rounding of the four cancelling terms is relative to the Plummer pull
|
||||
Assert.InRange(zone.Wells.PullAround(node, r, default), expected - 1e-5 * scale, expected + 1e-5 * scale);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ internal sealed class ZoneWorlds : IDisposable
|
|||
WellStrength = new ExponentialCurve { Exponent = .2f, Multiplier = 45.08f },
|
||||
RocheLimit = new ExponentialCurve { Exponent = .25f, Multiplier = 7.32f },
|
||||
BodyRadius = new ExponentialCurve { Exponent = .25f, Multiplier = 3f },
|
||||
LightRadius = new ExponentialCurve()
|
||||
LightRadius = new ExponentialCurve(),
|
||||
AsteroidSize = new ExponentialLerp { Minimum = 2f, Maximum = 9f, Exponent = 1.7f }
|
||||
};
|
||||
|
||||
public sealed class World
|
||||
|
|
|
|||
Loading…
Reference in a new issue