Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PVG cleanup: replace ResidualWrapper with ContinuityLayout/ResidualLa…
…yout also cleans up the "Problem" a bit and removes that one last annoying null warning i've left in for about a year. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
- Loading branch information
1 parent
9d9f9c6
commit 118a797
Showing
9 changed files
with
446 additions
and
477 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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,56 @@ | ||
/* | ||
* Copyright Lamont Granquist, Sebastien Gaggini and the MechJeb contributors | ||
* SPDX-License-Identifier: LicenseRef-PD-hp OR Unlicense OR CC0-1.0 OR 0BSD OR MIT-0 OR MIT OR LGPL-2.1+ | ||
*/ | ||
|
||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
using MechJebLib.Primitives; | ||
|
||
namespace MechJebLib.PVG | ||
{ | ||
public class ContinuityLayout | ||
{ | ||
public const int CONTINUITY_LAYOUT_LEN = ResidualLayout.RESIDUAL_LAYOUT_LEN; | ||
|
||
public V3 R; | ||
public V3 V; | ||
public V3 Pv; | ||
public V3 Pr; | ||
public double M; | ||
public double Pm; | ||
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); | ||
V.CopyFrom(other, 3); | ||
Pv.CopyFrom(other, 6); | ||
Pr.CopyFrom(other, 9); | ||
M = other[12]; | ||
Pm = other[13]; | ||
Bt = other[14]; | ||
} | ||
|
||
public static ContinuityLayout CreateFrom(IList<double> other) | ||
{ | ||
var a = new ContinuityLayout(); | ||
|
||
a.CopyFrom(other); | ||
|
||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright Lamont Granquist, Sebastien Gaggini and the MechJeb contributors | ||
* SPDX-License-Identifier: LicenseRef-PD-hp OR Unlicense OR CC0-1.0 OR 0BSD OR MIT-0 OR MIT OR LGPL-2.1+ | ||
*/ | ||
|
||
#nullable enable | ||
|
||
using System.Collections.Generic; | ||
using MechJebLib.Primitives; | ||
|
||
namespace MechJebLib.PVG | ||
{ | ||
public class ResidualLayout | ||
{ | ||
public const int RESIDUAL_LAYOUT_LEN = 15; | ||
|
||
public V3 R; | ||
public V3 V; | ||
private V3 _terminal0; | ||
private V3 _terminal1; | ||
public double M; | ||
public double Bt; | ||
public double Pm; | ||
|
||
public (double a, double b, double c, double d, double e, double f) Terminal | ||
{ | ||
set | ||
{ | ||
_terminal0[0] = value.a; | ||
_terminal0[1] = value.b; | ||
_terminal0[2] = value.c; | ||
_terminal1[0] = value.d; | ||
_terminal1[1] = value.e; | ||
_terminal1[2] = value.f; | ||
} | ||
} | ||
|
||
public void CopyTo(IList<double> other) | ||
{ | ||
R.CopyTo(other); | ||
V.CopyTo(other, 3); | ||
other[6] = M; | ||
other[7] = _terminal0[0]; | ||
other[8] = _terminal0[1]; | ||
other[9] = _terminal0[2]; | ||
other[10] = _terminal1[0]; | ||
other[11] = _terminal1[1]; | ||
other[12] = _terminal1[2]; | ||
other[13] = Pm; | ||
other[14] = Bt; | ||
} | ||
|
||
public void CopyFrom(IList<double> other) | ||
{ | ||
R.CopyFrom(other); | ||
V.CopyFrom(other, 3); | ||
M = other[6]; | ||
_terminal0 = new V3(other[7], other[8], other[9]); | ||
_terminal1 = new V3(other[10], other[11], other[12]); | ||
Pm = other[13]; | ||
Bt = other[14]; | ||
} | ||
|
||
public static ResidualLayout CreateFrom(IList<double> other) | ||
{ | ||
var a = new ResidualLayout(); | ||
|
||
a.CopyFrom(other); | ||
|
||
return a; | ||
} | ||
} | ||
} |
Oops, something went wrong.