Arm solve: nearest feasible swivel when zero twist leaves the cone; seated ward test per wrist, gravity off and on

The seated ward-off wrists fell short with gravity off as well: the zero-twist
swivel saturated the shoulder cone 20 to 23 cm short of head-height ward goals
that a swivel with 0.27 to 0.52 rad twist reaches inside the limits. The solver
now takes the swivel nearest zero twist that is inside the cone and the twist
limits (Tolani, Goswami and Badler 2000), clamping only when none is.

The seated test measures each wrist against its own ward goal: gravity off at
the head-height sounds (both arms, 7.0 cm worst) and the near arm at a low
sound, and gravity on separately. Bounds by deterministic-bound-margin; the
sideways, no-spread, half-spread, half-weight and zero-twist mutants are killed.
The far arm at the low sound wedges against the trunk (goal-ai-map fact 8).

Finding: lodur:finding:cut-lodur-orient-goals.s1.seated-ward-bound-vacuous

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-26 01:01:58 +01:00
commit 4e056c24f8
4 changed files with 192 additions and 55 deletions

View file

@ -44,6 +44,13 @@ scratch project `imag-goals/probe` (not committed); humanoid, 120 Hz, 4 substeps
8. **Zero-twist two-bone solve (probe).** Choosing the elbow swivel so the shoulder target has no twist is
closed form: `R = Rot(v, phi) * Arc(p, v)`, `phi/2 = atan2(-Q.y, w v.y + (v x Q).y)` with `(Q, w) = Arc(p, v)`
and y the creation-pose bone axis; the result is unique. Arm lengths: L1 0.310 m, L2 0.265 m (anchors).
That swivel can push the swing past the shoulder cone where another swivel reaches: the seated ward-off goals at
head height (`(0.30, 1.74, 0.26)` left, `(0.00, 1.74, 0.26)` right) clamp 20.5 and 22.6 cm short at zero twist and
are reached at twist 0.27 and 0.52 inside the [-1, 1] limits. At gravity 0 the twist muscle holds those to 0.54
and 0.44 and the wrists land 7.0 and 2.8 cm off (probe, cut `lodur-orient-goals` s1 fix).
Across the body, a goal the zero-twist swivel reaches can still be missed: the right arm swinging toward
`(-0.04, 1.60, 0.24)` drives its forearm into the side of the trunk and wedges there, 45 cm short at gravity 0
(two forearm contacts, swing 0.20 against 1.50); a forward via point for 0.6 s first brings it to 9.8 cm.
9. **Reach on the ragdoll (probe).** Solving each step from the measured torso frame, wrist error after 4 s,
right arm, targets at shoulder plus an offset. Gravity 0, free-floating: `(0,-0.25,0.35)` 3.0 cm,
`(0.12,-0.1,0.4)` 11.1 cm (swing 1.22 near the 1.5 cone, across the body), `(-0.15,-0.3,0.25)` 2.3 cm,
@ -246,8 +253,10 @@ consideration input to its Select.
Lodur.Core, as Final IK feeds PuppetMaster's target pose, not a solver in the binding: the binding stays the
muscle layer and the will mix and graft mask see IK like any other layer. Arms are two-bone with a hinge elbow,
so the analytic solve is exact; FABRIK and CCD wait for graft chains that are not two-bone. The elbow swivel is
the one needing no shoulder twist, because the shoulder's twist muscle cannot hold one (fact 7); what this gives
up is an authored elbow direction. Reach under gravity lands short by PD sag (fact 9); that is its own cut.
the one needing no shoulder twist, because the shoulder's twist muscle tracks a twist weakly (fact 7); what this
gives up is an authored elbow direction. Where that swivel leaves the cone, the swivel is the nearest one inside
the cone and the twist limits, the feasible swivel range of Tolani, Goswami and Badler (2000); the swing clamps
only when no swivel is feasible (fact 8). Reach under gravity lands short by PD sag (fact 9); that is its own cut.
**Goal-target rationale.** A target is tracked by percept Id (fact 11), selection scores (goal, percept) pairs,
and a retarget inside the goal waits the deliberate latency but not the dwell, held only by the commitment

View file

@ -85,14 +85,20 @@ namespace Lodur
/// <summary>
/// A two-bone arm: shoulder (spherical), elbow (revolute) and wrist anchors of one side, found by label in the plan. Solves a world
/// point for the wrist anchor with zero shoulder twist: the elbow flex is fixed by the distance, and the swivel about the shoulder-to-wrist
/// line is the one that leaves the shoulder target no twist.
/// point for the wrist anchor: the elbow flex is fixed by the distance, and the swivel about the shoulder-to-wrist line is the one that
/// leaves the shoulder target no twist, the shoulder's twist muscle being weak. When that swivel puts the swing past the cone, the swivel
/// is the one nearest it whose swing is inside the cone and whose twist is inside the twist limits (the joint-limit-feasible swivel range of
/// Tolani, Goswami and Badler 2000); only when no swivel is feasible does the swing clamp to the cone.
/// </summary>
public sealed class ArmChain
{
private readonly Quat _parentRestInverse, _frame, _frameInverse;
private readonly IkVec _parentCentre, _shoulderAnchor, _upper, _lower, _elbowAxis, _twistAxis;
private readonly float _flexSign, _flexLo, _flexHi, _cone;
private readonly float _flexSign, _flexLo, _flexHi, _cone, _twistLo, _twistHi, _coneSin2;
// Swivel search: steps of Pi / SwivelSteps outward from the zero-twist swivel, then bisection to the feasible boundary.
private const int SwivelSteps = 90;
private const int SwivelBisections = 16;
private ArmChain(BodyPlan plan, Side side)
{
@ -132,6 +138,10 @@ namespace Lodur
_flexLo = e.Lower;
_flexHi = e.Upper;
_cone = s.Cone;
_twistLo = s.Lower;
_twistHi = s.Upper;
var half = MathF.Sin(0.5f * _cone);
_coneSin2 = half * half;
_shoulderAnchor = shoulder;
_frame = Ik.JointFrame(s);
_frameInverse = _frame.Conjugate();
@ -188,14 +198,13 @@ namespace Lodur
var q = new IkVec(arc.X, arc.Y, arc.Z);
var num = -q.Dot(_twistAxis);
var den = arc.W * vHat.Dot(_twistAxis) + vHat.Cross(q).Dot(_twistAxis);
var swing = Ik.About(vHat, 2f * MathF.Atan2(num, den)) * arc;
var local = _frameInverse * swing * _frame;
if (local.W < 0f) local = new Quat(-local.X, -local.Y, -local.Z, -local.W);
var vecLen = MathF.Sqrt(local.X * local.X + local.Y * local.Y + local.Z * local.Z);
var angle = 2f * MathF.Atan2(vecLen, local.W);
if (angle > _cone)
var zeroTwist = 2f * MathF.Atan2(num, den);
var local = Local(vHat, arc, zeroTwist);
if (!InsideCone(local) && !NearestFeasible(vHat, arc, zeroTwist, out local))
{
// No swivel is feasible: the zero-twist swing, clamped to the cone.
local = Local(vHat, arc, zeroTwist);
var vecLen = MathF.Sqrt(local.X * local.X + local.Y * local.Y + local.Z * local.Z);
local = Quat.FromAxisAngle(local.X / vecLen, local.Y / vecLen, local.Z / vecLen, _cone);
reached = false;
}
@ -204,6 +213,62 @@ namespace Lodur
elbow = Quat.FromAxisAngle(0f, 0f, 1f, flex);
return reached;
}
// The shoulder target in the joint frame for the swivel phi about vHat, with w >= 0.
private Quat Local(IkVec vHat, in Quat arc, float phi)
{
var local = _frameInverse * (Ik.About(vHat, phi) * arc) * _frame;
return local.W < 0f ? new Quat(-local.X, -local.Y, -local.Z, -local.W) : local;
}
// Swing is the angle between the frame z and its image: inside the cone when sin^2(swing / 2) = x^2 + y^2 <= sin^2(cone / 2).
private bool InsideCone(in Quat local) => local.X * local.X + local.Y * local.Y <= _coneSin2;
private bool Feasible(in Quat local)
{
if (!InsideCone(local)) return false;
var twist = 2f * MathF.Atan2(local.Z, local.W);
return twist >= _twistLo && twist <= _twistHi;
}
// The feasible swivel nearest phi0: step outward both ways, and at the first step that lands inside, bisect back to the boundary;
// of the two sides, the one with the smaller twist. False when no swivel is feasible.
private bool NearestFeasible(IkVec vHat, in Quat arc, float phi0, out Quat local)
{
local = default;
const float step = MathF.PI / SwivelSteps;
for (var k = 1; k <= SwivelSteps; k++)
{
var found = false;
var bestTwist = float.MaxValue;
for (var sign = -1; sign <= 1; sign += 2)
{
var phi = phi0 + sign * k * step;
if (!Feasible(Local(vHat, arc, phi))) continue;
var inside = phi;
var outside = phi0 + sign * (k - 1) * step;
for (var b = 0; b < SwivelBisections; b++)
{
var mid = 0.5f * (inside + outside);
if (Feasible(Local(vHat, arc, mid))) inside = mid;
else outside = mid;
}
var candidate = Local(vHat, arc, inside);
var twist = MathF.Abs(2f * MathF.Atan2(candidate.Z, candidate.W));
if (twist < bestTwist)
{
bestTwist = twist;
local = candidate;
found = true;
}
}
if (found) return true;
}
return false;
}
}
/// <summary>

View file

@ -86,18 +86,46 @@ public sealed class IkTests
[Theory]
[InlineData(Side.Left)]
[InlineData(Side.Right)]
public void Arm_solve_never_twists_the_shoulder(Side side)
public void Arm_solve_twists_the_shoulder_only_where_zero_twist_would_leave_the_cone(Side side)
{
var arm = ArmChain.Of(Plan, side);
var n = 0;
var joint = Plan.Joints[arm.ShoulderJoint];
var (n, twisted) = (0, 0);
foreach (var (rot, pos, target) in Grid(arm, 21 + (int)side, 600))
{
arm.Solve(rot, pos.X, pos.Y, pos.Z, target.X, target.Y, target.Z, out var sq, out _);
Assert.True(ZTwist(sq) < 1e-5f, $"shoulder target twists by {ZTwist(sq)} rad for {target}");
var swing = 2f * MathF.Asin(MathF.Min(1f, MathF.Sqrt(sq.X * sq.X + sq.Y * sq.Y)));
var twist = 2f * MathF.Atan2(sq.Z, sq.W);
Assert.True(swing <= joint.Cone + 1e-4f, $"swing {swing} past the cone {joint.Cone} for {target}");
Assert.True(twist >= joint.Lower - 1e-4f && twist <= joint.Upper + 1e-4f, $"twist {twist} outside [{joint.Lower}, {joint.Upper}] for {target}");
if (MathF.Abs(twist) > 1e-5f)
{
// A twist is taken only to keep the swing inside the cone, so the swivel sits on the boundary of the feasible range.
twisted++;
var onLimit = MathF.Abs(swing - joint.Cone) < 1e-3f || MathF.Abs(twist - joint.Lower) < 1e-3f || MathF.Abs(twist - joint.Upper) < 1e-3f;
Assert.True(onLimit, $"shoulder target twists by {twist} rad at swing {swing} for {target}, off every limit");
}
n++;
}
Assert.Equal(600, n);
Assert.InRange(twisted, 1, n / 2);
}
[Fact]
public void A_wrist_goal_the_zero_twist_swivel_cannot_reach_is_reached_by_twisting_inside_the_limits()
{
// The left ward-off wrist goal for a sound at head height, ahead and to the left: zero twist saturates the cone 20 cm short.
var arm = ArmChain.Of(Plan, Side.Left);
var joint = Plan.Joints[arm.ShoulderJoint];
var centre = Plan.Parts[arm.ParentPart].Position;
var goal = (0.2988f, 1.74f, 0.2605f);
Assert.True(arm.Solve(Quat.Identity, centre.X, centre.Y, centre.Z, goal.Item1, goal.Item2, goal.Item3, out var sq, out var eq));
var wrist = Wrist(arm, Quat.Identity, centre, sq, eq);
Assert.True(Len(Sub(wrist, goal)) < 1e-3f, $"wrist {wrist} missed {goal} by {Len(Sub(wrist, goal))} m");
var twist = 2f * MathF.Atan2(sq.Z, sq.W);
Assert.True(MathF.Abs(twist) > 0.05f && twist >= joint.Lower && twist <= joint.Upper, $"twist {twist}");
}
[Fact]

View file

@ -6,7 +6,7 @@ using Ymir.Box3D;
namespace Lodur.Tests;
/// <summary>
/// The orient layers on the real body: a ragdoll seated on a stool welded to the pelvis, gravity on, a sound at one side. An Actor whose goal looks
/// The orient layers on the real body: a ragdoll seated on a stool welded to the pelvis, without and with gravity, a sound at one side. An Actor whose goal looks
/// at it and wards it off drives the ragdoll through strengths and targets only; the game (this scenario) reads the part poses, owns the world and steps it.
/// </summary>
public sealed class SeatedOrientTests
@ -14,25 +14,45 @@ public sealed class SeatedOrientTests
private const float Dt = 1f / 120f;
private const uint Thing = 7;
private const float WardDistance = 0.3f;
private const float Spread = 0.15f;
private static readonly BodyPlan Plan = BodyPlans.Humanoid();
/// <summary>Where the sound sits for each case: well to one side and a little ahead, at head height and beyond the arms reach.</summary>
private static readonly (float X, float Y, float Z)[] Sounds = { (0.4f, 1.74f, 0.7f), (-0.4f, 1.74f, 0.7f) };
/// <summary>
/// Head forward error bound after 2 s, degrees, at the geometric midpoint (deterministic-bound-margin) of the shipped worst, 0.040 deg over the two
/// sounds, and the least claimed mutant, 15.157 deg (the look blended at half weight): separation 379. Also killed: look not applied, 30.6 deg;
/// the look aimed at the target mirrored in x, 60.2 deg. Layers off reads 29.9 deg.
/// A lower sound to the left, whose ward goals the near (left) arm reaches with zero shoulder twist. The far arm's goal crosses the midline, and
/// its swing toward it drives the forearm into the side of the trunk, where it wedges (44.6 cm off, gravity or not): the far arm is not claimed here.
/// </summary>
private const float LookBoundDegrees = 0.78f;
private static readonly (float X, float Y, float Z) LowSound = (0.4f, 1.2f, 0.9f);
/// <summary>
/// Bound on the mean wrist distance to the head-to-sound line after 2 s, metres, at the geometric midpoint of the shipped worst, 51.67 cm, and the least
/// claimed mutant, 78.67 cm (the arms layer not applied, which reads the spawn value): separation 1.52. The ward-off wrists sit short of the line under gravity
/// (follow-up lodur-reach-tracking), so the bound proves they rose toward it, not that they met it. Unclaimed: the wrists sent sideways of the line by the
/// ward distance instead of along it reads 62.44 and 57.76 cm, separation 1.12 against the shipped worst, which this metric does not separate.
/// Head forward error bound after 2 s, degrees, at the geometric midpoint (deterministic-bound-margin) of the shipped worst, 1.030 deg over the two
/// sounds with and without gravity, and the least claimed mutant, 15.233 deg (the look blended at half weight): separation 14.8. Layers off reads 29.7 deg.
/// </summary>
private const float WardBound = 0.6376f;
private const float LookBoundDegrees = 3.961f;
/// <summary>
/// Without gravity, bound on each wrist's distance to its own ward goal after 2 s at the head-height sounds, metres: the geometric midpoint of the shipped
/// worst, 7.00 cm, and the least claimed mutant, 16.23 cm (no spread: both wrists on the line). Also killed: the wrists sent sideways of the head by the
/// ward distance, 27.72 cm; spread halved and offset 0.1 m, 19.36 cm; the arms blended at half weight, 27.51 cm; the zero-twist swivel clamped to the
/// shoulder cone (the solver before the feasible-swivel search), 64.94 cm. Layers off reads the start, 81.3 and 83.5 cm.
/// </summary>
private const float WardBound = 0.1066f;
/// <summary>
/// Without gravity, bound on the near (left) wrist's distance to its ward goal at the low sound: the geometric midpoint of the shipped 4.34 cm and the
/// least claimed mutant, 11.41 cm (the arms at half weight). Also killed: sideways, 16.64 cm; no spread, 20.10 cm.
/// </summary>
private const float NearWardBound = 0.0704f;
/// <summary>
/// Under gravity, the head-height bound on each wrist: the geometric midpoint of the shipped worst, 17.79 cm, and the least claimed mutant, 36.84 cm (no
/// spread). Also killed: spread halved and offset, 53.28 cm; the arms at half weight, 44.24 cm; the clamped zero-twist swivel, 68.58 cm. The 11 to 13 cm
/// over the zero-gravity case is the shoulder sagging under the arm's weight (swing 1.11 against a target of 1.50): follow-up lodur-reach-tracking.
/// Unclaimed: the sideways mutant reads 23.92 cm, separation 1.34.
/// </summary>
private const float GravityWardBound = 0.2560f;
private readonly ITestOutputHelper _out;
@ -54,7 +74,7 @@ public sealed class SeatedOrientTests
return pose;
}
private static Brain Watching(bool layered) => new()
private static Brain Watching() => new()
{
Goals = new[]
{
@ -66,25 +86,25 @@ public sealed class SeatedOrientTests
Behaviour = new PoseBehaviour
{
Keys = new[] { Held() }, FlinchPose = Held(),
Look = layered ? new LookLayer() : null,
Arms = layered ? new ArmLayer { Mode = ArmMode.WardOff, Side = ArmSide.Both, Distance = WardDistance, Spread = 0.15f } : null,
Look = new LookLayer(),
Arms = new ArmLayer { Mode = ArmMode.WardOff, Side = ArmSide.Both, Distance = WardDistance, Spread = Spread },
},
},
},
};
/// <summary>Seats the body, sounds the emitter for two seconds and returns the head forward's error to the sound bearing (radians) and the mean wrist distance to the head-to-sound line, at the end and at the start.</summary>
private static (float Look, float WardEnd, float WardStart, ulong Target) Run((float X, float Y, float Z) sound, bool layered)
/// <summary>Seats the body, sounds the emitter for two seconds and returns the head forward's error to the sound bearing (radians) and each wrist's distance to its ward goal at the end and at the start.</summary>
private static (float Look, float Left, float Right, float LeftStart, float RightStart, ulong Target) Run((float X, float Y, float Z) sound, float gravity)
{
var (bodies, joints, _) = Ragdoll.Needs(Plan);
using var world = new Box3DSoaWorld(capacity: bodies + 2, jointCapacity: joints + 1);
using var world = new Box3DSoaWorld(capacity: bodies + 2, gravityY: gravity, jointCapacity: joints + 1);
world.AddStaticBox(1, (0f, -0.5f, 0f), (20f, 0.5f, 20f), friction: 0.8f);
var stool = world.AddStaticBox(2, (0f, 1.11f, -0.115f), (0.05f, 0.05f, 0.025f), friction: 0.8f);
var ragdoll = Ragdoll.Build(world, Plan, (0f, 0f), firstStableId: 100);
world.AddJoint(Box3DSoaJointKind.Weld, stool, ragdoll.BodyLane(Plan.PartIndex("Pelvis")), (0f, 1.11f, -0.09f), (0f, 1f, 0f));
var senseHead = Plan.SenseIndex("Head");
var actor = new Actor(Dt, Plan.SensePoints.Count, new NerveParameters(), new WithdrawalParameters(), new DriveParameters(), Watching(layered),
var actor = new Actor(Dt, Plan.SensePoints.Count, new NerveParameters(), new WithdrawalParameters(), new DriveParameters(), Watching(),
new NerveParameters { Threshold = 0.05, SensitisationGrowth = 0.0, ConductionDelaySeconds = 0.0 }, senseHead,
new PerceptParameters { Capacity = 4, MemorySeconds = 5.0 }, body: Plan);
var x = new float[Plan.SensePoints.Count]; var y = new float[x.Length]; var z = new float[x.Length];
@ -95,27 +115,26 @@ public sealed class SeatedOrientTests
var head = Plan.PartIndex("Head");
var wrists = new[] { Plan.JointIndex("Wrist", Side.Left), Plan.JointIndex("Wrist", Side.Right) };
float WristError()
var torso = Plan.PartIndex("Torso");
// Each wrist's distance to its own ward-off goal: the head centre plus Distance toward the sound plus Spread along the torso's left
// axis, the left wrist to the left. The goal is rebuilt from the measured head and torso, as the layer builds it.
float WristError(int k)
{
var h = parts[head];
var u = Unit((sound.X - h.X, sound.Y - h.Y, sound.Z - h.Z));
var sum = 0f;
foreach (var w in wrists)
{
var j = Plan.Joints[w];
var fore = parts[j.Parent];
var c = Plan.Parts[j.Parent].Position;
fore.Rotation.Rotate(j.Anchor.X - c.X, j.Anchor.Y - c.Y, j.Anchor.Z - c.Z, out var ox, out var oy, out var oz);
var q = (X: fore.X + ox - h.X, Y: fore.Y + oy - h.Y, Z: fore.Z + oz - h.Z);
var along = q.X * u.X + q.Y * u.Y + q.Z * u.Z;
sum += MathF.Sqrt(MathF.Max(0f, q.X * q.X + q.Y * q.Y + q.Z * q.Z - along * along));
}
return sum / wrists.Length;
parts[torso].Rotation.Rotate(1f, 0f, 0f, out var lx, out var ly, out var lz);
var across = k == 0 ? Spread : -Spread;
var goal = (h.X + u.X * WardDistance + lx * across, h.Y + u.Y * WardDistance + ly * across, h.Z + u.Z * WardDistance + lz * across);
var j = Plan.Joints[wrists[k]];
var fore = parts[j.Parent];
var c = Plan.Parts[j.Parent].Position;
fore.Rotation.Rotate(j.Anchor.X - c.X, j.Anchor.Y - c.Y, j.Anchor.Z - c.Z, out var ox, out var oy, out var oz);
return Dist((fore.X + ox, fore.Y + oy, fore.Z + oz), goal);
}
ragdoll.ReadPartPoses(parts);
var start = WristError();
var (leftStart, rightStart) = (WristError(0), WristError(1));
for (var i = 0; i < (int)MathF.Round(2f / Dt); i++)
{
ragdoll.ReadSensePoints(x, y, z);
@ -130,7 +149,7 @@ public sealed class SeatedOrientTests
hp.Rotation.Rotate(0f, 0f, 1f, out var fx, out var fy, out var fz);
var bearing = Unit((sound.X - hp.X, sound.Y - hp.Y, sound.Z - hp.Z));
var cos = Math.Clamp(fx * bearing.X + fy * bearing.Y + fz * bearing.Z, -1f, 1f);
return (MathF.Acos(cos), WristError(), start, actor.TargetId);
return (MathF.Acos(cos), WristError(0), WristError(1), leftStart, rightStart, actor.TargetId);
}
[Fact]
@ -158,16 +177,32 @@ public sealed class SeatedOrientTests
}
[Fact]
public void A_seated_body_looks_at_the_sound_and_wards_it_off()
public void Without_gravity_a_seated_body_looks_at_the_sound_and_its_wrists_meet_the_ward_goals()
{
for (var s = 0; s < Sounds.Length; s++)
{
var (look, wardEnd, wardStart, target) = Run(Sounds[s], layered: true);
var (lookOff, wardOff, _, _) = Run(Sounds[s], layered: false);
_out.WriteLine($"sound {s}: head error {look * 57.2958f:F3} deg (layers off {lookOff * 57.2958f:F3}), wrists to the head-sound line {wardEnd * 100f:F2} cm (start {wardStart * 100f:F2}, layers off {wardOff * 100f:F2}), target {target}");
Assert.Equal(1UL, target);
Assert.True(look * 57.2958f < LookBoundDegrees, $"head forward is {look * 57.2958f:F2} deg off the sound, bound {LookBoundDegrees} deg");
Assert.True(wardEnd < WardBound && wardEnd < wardStart, $"wrists are {wardEnd * 100f:F1} cm from the head-sound line (start {wardStart * 100f:F1}), bound {WardBound * 100f:F1} cm");
var r = Run(Sounds[s], gravity: 0f);
_out.WriteLine($"sound {s}: head error {r.Look * 57.2958f:F3} deg, wrists to their goals {r.Left * 100f:F2} and {r.Right * 100f:F2} cm (start {r.LeftStart * 100f:F2} and {r.RightStart * 100f:F2}), target {r.Target}");
Assert.Equal(1UL, r.Target);
Assert.True(r.Look * 57.2958f < LookBoundDegrees, $"head forward is {r.Look * 57.2958f:F2} deg off the sound, bound {LookBoundDegrees} deg");
Assert.True(r.Left < WardBound && r.Right < WardBound, $"wrists are {r.Left * 100f:F1} and {r.Right * 100f:F1} cm from their goals, bound {WardBound * 100f:F1} cm");
}
var low = Run(LowSound, gravity: 0f);
_out.WriteLine($"low sound: wrists to their goals {low.Left * 100f:F2} and {low.Right * 100f:F2} cm");
Assert.True(low.Left < NearWardBound, $"the near wrist is {low.Left * 100f:F1} cm from its goal, bound {NearWardBound * 100f:F1} cm");
}
[Fact]
public void Under_gravity_a_seated_body_looks_at_the_sound_and_its_wrists_rise_toward_the_ward_goals()
{
for (var s = 0; s < Sounds.Length; s++)
{
var r = Run(Sounds[s], gravity: -10f);
_out.WriteLine($"sound {s}: head error {r.Look * 57.2958f:F3} deg, wrists to their goals {r.Left * 100f:F2} and {r.Right * 100f:F2} cm (start {r.LeftStart * 100f:F2} and {r.RightStart * 100f:F2}), target {r.Target}");
Assert.Equal(1UL, r.Target);
Assert.True(r.Look * 57.2958f < LookBoundDegrees, $"head forward is {r.Look * 57.2958f:F2} deg off the sound, bound {LookBoundDegrees} deg");
Assert.True(r.Left < GravityWardBound && r.Right < GravityWardBound, $"wrists are {r.Left * 100f:F1} and {r.Right * 100f:F1} cm from their goals, bound {GravityWardBound * 100f:F1} cm");
}
}
}