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
@@ -8,6 +8,9 @@ public static class OriginalHeading
|
||||
private static readonly ushort[] halfAcos = BuildHalfAcos();
|
||||
|
||||
public static float Degrees(Vector3 vector)
|
||||
=> HeadingUnits(vector) * 0.02197265625f;
|
||||
|
||||
private static int HeadingUnits(Vector3 vector)
|
||||
{
|
||||
if (!float.IsFinite(vector.X) || !float.IsFinite(vector.Y) || !float.IsFinite(vector.Z))
|
||||
throw new ArgumentOutOfRangeException(nameof(vector), "A finite direction is required.");
|
||||
@@ -24,7 +27,29 @@ public static class OriginalHeading
|
||||
angle = x < 0 ? 8192 + angle : 8192 - angle;
|
||||
else if (x < 0)
|
||||
angle = 16384 - angle;
|
||||
return ((-angle) & 0x3fff) * 0.02197265625f;
|
||||
return (-angle) & 0x3fff;
|
||||
}
|
||||
|
||||
/// <summary>Copied OMT2 vector::angles pitch/yaw, in signed14-bit circle units.</summary>
|
||||
public static (int Pitch,int Yaw) Angles(Vector3 vector)
|
||||
{
|
||||
var heading=HeadingUnits(vector);
|
||||
var radians=((-heading)&16383)*(Math.Tau/16384);
|
||||
float sine=(float)Math.Sin(radians), cosine=(float)Math.Cos(radians);
|
||||
var h=(double)vector.X*sine+(double)vector.Z*cosine;
|
||||
double y=vector.Y;
|
||||
int value=0;
|
||||
if (h!=0||y!=0)
|
||||
{
|
||||
var index=(int)(16384*y*y/(h*h+y*y));
|
||||
value=halfAcos[Math.Clamp(index,0,16384)];
|
||||
if(y<0) value=h<0 ? 8192+value : 8192-value;
|
||||
else if(h<0) value=16384-value;
|
||||
}
|
||||
var pitch=(4096-value)&16383;
|
||||
if(pitch>8192)pitch-=16384;
|
||||
if(heading>8192)heading-=16384;
|
||||
return (pitch,heading);
|
||||
}
|
||||
|
||||
private static ushort[] BuildHalfAcos()
|
||||
|
||||
Reference in new issue
Block a user