mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Improve orbital velocity calculation
This commit is contained in:
parent
5a00065ba7
commit
d68291c628
@ -60,7 +60,7 @@ namespace NewHorizons.Builder.Orbital
|
|||||||
|
|
||||||
orbitLine._astroObject = astroobject;
|
orbitLine._astroObject = astroobject;
|
||||||
orbitLine._fade = fade;
|
orbitLine._fade = fade;
|
||||||
orbitLine._lineWidth = 1f;
|
orbitLine._lineWidth = 2f;
|
||||||
|
|
||||||
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(orbitLine.InitializeLineRenderer);
|
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(orbitLine.InitializeLineRenderer);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,13 +95,15 @@ namespace NewHorizons.Components.Orbital
|
|||||||
var R3 = Quaternion.AngleAxis(argumentOfPeriapsis, Vector3.up);
|
var R3 = Quaternion.AngleAxis(argumentOfPeriapsis, Vector3.up);
|
||||||
|
|
||||||
var n_p = new Vector2(x, y).normalized;
|
var n_p = new Vector2(x, y).normalized;
|
||||||
var n_v = new Vector2(-y, x).normalized;
|
|
||||||
|
|
||||||
var pos = new Vector3(r * n_p.x, 0f, r * n_p.y);
|
var dir = R1 * R2 * R3 * new Vector3(n_p.x, 0f, n_p.y).normalized;
|
||||||
var vel = new Vector3(v * n_v.x, 0f, v * n_v.y);
|
var up = R1 * R2 * R3 * Vector3.up;
|
||||||
|
|
||||||
orbitalParameters.InitialPosition = R1 * R2 * R3 * pos;
|
var pos = r * dir;
|
||||||
orbitalParameters.InitialVelocity = R1 * R2 * R3 * vel;
|
var vel = v * Vector3.Cross(dir, up).normalized;
|
||||||
|
|
||||||
|
orbitalParameters.InitialPosition = pos;
|
||||||
|
orbitalParameters.InitialVelocity = vel;
|
||||||
|
|
||||||
return orbitalParameters;
|
return orbitalParameters;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user