mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Eccentric around linear gravity = tracking orbit
This commit is contained in:
parent
48479f87d8
commit
2c561d7c19
@ -35,17 +35,25 @@ namespace NewHorizons.Builder.Orbital
|
|||||||
|
|
||||||
var parentGravity = astroObject.GetPrimaryBody()?.GetGravityVolume();
|
var parentGravity = astroObject.GetPrimaryBody()?.GetGravityVolume();
|
||||||
|
|
||||||
NHOrbitLine orbitLine = orbitGO.AddComponent<NHOrbitLine>();
|
OrbitLine orbitLine;
|
||||||
|
if(parentGravity?.GetFalloffExponent() == 1 && ecc != 0)
|
||||||
|
{
|
||||||
|
orbitLine = orbitGO.AddComponent<TrackingOrbitLine>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
orbitLine = orbitGO.AddComponent<NHOrbitLine>();
|
||||||
|
|
||||||
var a = astroObject.SemiMajorAxis;
|
var a = astroObject.SemiMajorAxis;
|
||||||
var e = astroObject.Eccentricity;
|
var e = astroObject.Eccentricity;
|
||||||
var b = a * Mathf.Sqrt(1f - (e * e));
|
var b = a * Mathf.Sqrt(1f - (e * e));
|
||||||
var l = astroObject.LongitudeOfAscendingNode;
|
var l = astroObject.LongitudeOfAscendingNode;
|
||||||
var p = astroObject.ArgumentOfPeriapsis;
|
var p = astroObject.ArgumentOfPeriapsis;
|
||||||
var i = astroObject.Inclination;
|
var i = astroObject.Inclination;
|
||||||
|
|
||||||
orbitLine.SemiMajorAxis = a * OrbitalParameters.Rotate(Vector3.left, l, i, p);
|
(orbitLine as NHOrbitLine).SemiMajorAxis = a * OrbitalParameters.Rotate(Vector3.left, l, i, p);
|
||||||
orbitLine.SemiMinorAxis = b * OrbitalParameters.Rotate(Vector3.forward, l, i, p);
|
(orbitLine as NHOrbitLine).SemiMinorAxis = b * OrbitalParameters.Rotate(Vector3.forward, l, i, p);
|
||||||
|
}
|
||||||
|
|
||||||
var color = Color.white;
|
var color = Color.white;
|
||||||
if (config.Orbit.Tint != null) color = config.Orbit.Tint.ToColor32();
|
if (config.Orbit.Tint != null) color = config.Orbit.Tint.ToColor32();
|
||||||
|
|||||||
@ -30,6 +30,13 @@ namespace NewHorizons.Components.Orbital
|
|||||||
orbitalParameters.LongitudeOfAscendingNode = longitudeOfAscendingNode;
|
orbitalParameters.LongitudeOfAscendingNode = longitudeOfAscendingNode;
|
||||||
orbitalParameters.Eccentricity = eccentricity;
|
orbitalParameters.Eccentricity = eccentricity;
|
||||||
orbitalParameters.ArgumentOfPeriapsis = argumentOfPeriapsis;
|
orbitalParameters.ArgumentOfPeriapsis = argumentOfPeriapsis;
|
||||||
|
|
||||||
|
// If primary gravity is linear and the orbit is eccentric its not even an ellipse so theres no true anomaly
|
||||||
|
if(primaryGravity.Power == 1 && eccentricity != 0)
|
||||||
|
{
|
||||||
|
trueAnomaly = 0;
|
||||||
|
}
|
||||||
|
|
||||||
orbitalParameters.TrueAnomaly = trueAnomaly;
|
orbitalParameters.TrueAnomaly = trueAnomaly;
|
||||||
|
|
||||||
// Have to calculate the rest
|
// Have to calculate the rest
|
||||||
@ -81,9 +88,7 @@ namespace NewHorizons.Components.Orbital
|
|||||||
var x = r * Mathf.Cos(f);
|
var x = r * Mathf.Cos(f);
|
||||||
var y = r * Mathf.Sin(f);
|
var y = r * Mathf.Sin(f);
|
||||||
|
|
||||||
var n_p = new Vector2(x, y).normalized;
|
var dir = Rotate(new Vector3(x, 0f, y).normalized, longitudeOfAscendingNode, inclination, argumentOfPeriapsis);
|
||||||
|
|
||||||
var dir = Rotate(new Vector3(n_p.x, 0f, n_p.y).normalized, longitudeOfAscendingNode, inclination, argumentOfPeriapsis);
|
|
||||||
var up = Rotate(Vector3.up, longitudeOfAscendingNode, inclination, argumentOfPeriapsis);
|
var up = Rotate(Vector3.up, longitudeOfAscendingNode, inclination, argumentOfPeriapsis);
|
||||||
|
|
||||||
var pos = r * dir;
|
var pos = r * dir;
|
||||||
|
|||||||
@ -15,7 +15,6 @@ namespace NewHorizons.Components.Orbital
|
|||||||
|
|
||||||
public float TrailTime = 120f;
|
public float TrailTime = 120f;
|
||||||
|
|
||||||
|
|
||||||
public override void InitializeLineRenderer()
|
public override void InitializeLineRenderer()
|
||||||
{
|
{
|
||||||
_lineRenderer.positionCount = this._numVerts;
|
_lineRenderer.positionCount = this._numVerts;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user