Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert the ArrayWrapper class to a struct
- causes more copying but removes the need to memorypool - weirdly this seems like it fixed a very tiny bug in the Titan2Tests - split the class up into input/output wrappers - they're no longer wrappers so i need a better name, TBD Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
- Loading branch information
1 parent
1f961fe
commit 26de45d
Showing
23 changed files
with
324 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using MechJebLib.Primitives; | ||
|
||
namespace MechJebLib.PVG | ||
{ | ||
public struct InputWrapper | ||
{ | ||
public const int INPUT_WRAPPER_LEN = 15; | ||
|
||
public V3 R; | ||
|
||
public V3 V; | ||
|
||
public V3 PV; | ||
|
||
public V3 PR; | ||
|
||
public double CostateMagnitude => Math.Sqrt(PR.sqrMagnitude + PV.sqrMagnitude); | ||
|
||
public double M; | ||
|
||
public double Pm; | ||
|
||
public double H0 | ||
{ | ||
get | ||
{ | ||
double rm = R.magnitude; | ||
return V3.Dot(PR, V) - | ||
V3.Dot(PV, R) / (rm * rm * rm); // FIXME: this changes for linear gravity model??!?!? | ||
} | ||
} | ||
|
||
public double Bt; | ||
|
||
public void CopyTo(IList<double> other) | ||
{ | ||
R.CopyTo(other); | ||
V.CopyTo(other, 3); | ||
PV.CopyTo(other, 6); | ||
PR.CopyTo(other, 9); | ||
other[12] = M; | ||
other[13] = Pm; | ||
other[14] = Bt; | ||
} | ||
|
||
public void CopyFrom(IList<double> other) | ||
{ | ||
R.CopyFrom(other, 0); | ||
V.CopyFrom(other, 3); | ||
PV.CopyFrom(other, 6); | ||
PR.CopyFrom(other, 9); | ||
M = other[12]; | ||
Pm = other[13]; | ||
Bt = other[14]; | ||
} | ||
|
||
public static InputWrapper CreateFrom(IList<double> other) | ||
{ | ||
var a = new InputWrapper(); | ||
|
||
a.R.CopyFrom(other); | ||
a.V.CopyFrom(other, 3); | ||
a.PV.CopyFrom(other, 6); | ||
a.PR.CopyFrom(other, 9); | ||
a.M = other[12]; | ||
a.Pm = other[13]; | ||
a.Bt = other[14]; | ||
|
||
return a; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.