Implement evidence-backed VR02 Rocketship flight and ownership
This commit is contained in:
1 parent
312efccb77
commit
e77add5fdf
50 files changed
+4326
-66
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using System.Numerics;
|
||||
using System.Text.Json;
|
||||
using GamePort.Game;
|
||||
|
||||
static class MotionReferences
|
||||
{
|
||||
public static void Run()
|
||||
{
|
||||
using var doc=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-motion-reference.json")));
|
||||
var cases=doc.RootElement.GetProperty("cases");
|
||||
if(cases.GetArrayLength()!=31)throw new Exception("Expected31 original motion/camera references");
|
||||
foreach(var item in cases.EnumerateArray())
|
||||
{
|
||||
var p=item.GetProperty("values");var label=item.GetProperty("name").GetString()!;
|
||||
float F(string name)=>p.GetProperty(name).GetSingle();
|
||||
Vector3 V(string name){var a=p.GetProperty(name);return new(a[0].GetSingle(),a[1].GetSingle(),a[2].GetSingle());}
|
||||
var kind=item.GetProperty("kind").GetString();
|
||||
if(kind=="TRANSFORM")
|
||||
{
|
||||
Near(RocketOrientation.Rotate(V("vector"),V("euler")),V("observed"),label);
|
||||
Near(Vector3.Transform(V("vector"),RocketOrientation.Model(V("euler"),Vector3.Zero,Vector3.One)),V("observed"),label+" model");
|
||||
}
|
||||
else if(kind=="MOTION")
|
||||
{
|
||||
var actual=RocketMotion.Apply(V("incoming"),V("euler"),F("speed"),F("bank"),F("previous"),F("dt"));
|
||||
Near(actual.Velocity,V("observed_velocity"),label);Near(actual.Rotation,V("observed_rotation"),label);
|
||||
Near(actual.PreviousBank,F("observed_previous"),label);
|
||||
}
|
||||
else if(kind=="AUX")
|
||||
{
|
||||
var timers=p.GetProperty("timer");var latches=p.GetProperty("latch");var pressed=p.GetProperty("pressed");
|
||||
var actual=RocketMotion.Apply(new(10,F("vy"),100),Vector3.Zero,400,16,7,F("dt"),
|
||||
new(timers[0].GetSingle(),timers[1].GetSingle(),latches[0].GetSingle()!=0,latches[1].GetSingle()!=0),
|
||||
pressed[0].GetSingle()!=0,pressed[1].GetSingle()!=0,F("suppressed")!=0);
|
||||
Near(actual.Velocity,V("observed_velocity"),label);Near(actual.Rotation,V("observed_rotation"),label);
|
||||
Near(actual.PreviousBank,F("observed_previous"),label);
|
||||
var expected=p.GetProperty("observed_timer");var expectedLatch=p.GetProperty("observed_latch");
|
||||
Near(actual.Maneuver.TurnRemaining,expected[0].GetSingle(),label);Near(actual.Maneuver.RollRemaining,expected[1].GetSingle(),label);
|
||||
if(actual.Maneuver.TurnLatched!=(expectedLatch[0].GetSingle()!=0)||actual.Maneuver.RollLatched!=(expectedLatch[1].GetSingle()!=0))
|
||||
throw new Exception(label+" original latch mismatch");
|
||||
}
|
||||
else if(kind=="FACING")Near(RocketOrientation.Face(V("euler"),V("dest"),F("dt")),V("observed_rotation"),label);
|
||||
else if(kind=="CAMERA")
|
||||
{
|
||||
Vector3 start=default,end=default;
|
||||
SupportHit? Ray(Vector3 a,Vector3 b){start=a;end=b;return F("hit")!=0?new(new(80,250,100),0,0,0):null;}
|
||||
var actual=RocketMotion.Follow(new(100,200,300),V("euler"),V("old"),F("dt"),Ray,(int)F("detail"));
|
||||
Near(start,V("trace_start"),label+" origin");Near(end,V("trace_end"),label+" endpoint");
|
||||
Near(actual.Eye,V("observed_eye"),label+" eye");
|
||||
if(actual.Pitch!=(int)F("pitch")||actual.Yaw!=(int)F("yaw"))throw new Exception($"{label} angles {actual.Pitch},{actual.Yaw}");
|
||||
}
|
||||
else throw new Exception("Unknown original fixture kind");
|
||||
}
|
||||
}
|
||||
|
||||
static void Near(Vector3 actual,Vector3 expected,string label)
|
||||
{
|
||||
Near(actual.X,expected.X,label+" X");Near(actual.Y,expected.Y,label+" Y");Near(actual.Z,expected.Z,label+" Z");
|
||||
}
|
||||
static void Near(float actual,float expected,string label)
|
||||
{
|
||||
if(!float.IsFinite(actual)||!float.IsFinite(expected)||MathF.Abs(actual-expected)>.002f)
|
||||
throw new Exception($"{label}: {actual} != {expected}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user