Gravity Engine 12.0
Unity Asset for Gravity
|
Calculate the universal Lambert transfer. This algorithm allows the transfer to be elliptic or hyperbolic as necessary to meet the designated transfer time. The transfer code can be used to determine the minimum energy transfer between the desired points/orbits - in this case the time of transfer is not specified. Additional API calls can be used to request a specific transfer time. It is frquently useful to obtain the most efficient transfer time and then use this as a baseline from which to investigate the dV cost of faster transfers. More...
Public Member Functions | |
LambertUniversal (OrbitData _fromOrbit, OrbitData _toOrbit, bool shortPath) | |
Setup for Lambert Universal construction. Calculation is done via ComputeXfer and may be done more than once for different transit times. | |
LambertUniversal (OrbitData _fromOrbit, Vector3d r_from, Vector3d r_to, bool shortPath) | |
Create a Lambert transfer from a given NBody orbit to a position in physics space. | |
void | SetPlanetRadius (double radius) |
Set the radius of the planet around which transfer is to be computed. This is used when calls to ComputeTransferWithPhasing(). In the event that the requested trajectory hits the planet. | |
void | ClearPlanetRadius () |
int | ComputeXferWithPhasing (bool reverse, bool df, int nrev, double dtsec, bool rendezvous) |
Determine the Lambert transfer in the specified time to the position that target object will be at in that time. If the rendezvous flag is set, then a maneuver will be generated to match the target. If not set then the ship will intercept the target. | |
Vector3d | GetR2 () |
Get the final position of the Lambert trajectory. Typically used when doing a xfer with phasing. | |
int | ComputeXfer (bool reverse, bool df, int nrev, double dtsec) |
Compute the transfer for the setup via the constructor for the specified transit time dtsec. | |
void | ComputeMinDvSquared (Vector3d r1_, Vector3d v1_, Vector3d r2_, Vector3d v2_) |
Compute the path from (r1,v1) to (r2,v2) that minimizes the value of (dV)^2. This uses the algorithm developed in "A closed-form solution to the minimum (delta Vtotal)^2 Lambert's Problem" by M. Avendano and D. Mortari, Celest.Mech.Dyn.Ast(2010) 106:25-37. | |
void | ComputeIntercept () |
Vector3d | GetTransferPositionDouble () |
Vector3 | GetTransferVelocity () |
Vector3d | GetTransferVelocityDouble () |
Vector3 | GetFinalVelocity () |
Vector3d | GetFinalVelocityDouble () |
double | GetTMin () |
Time of flight for minimum energy trajectory. | |
string | Log () |
Public Member Functions inherited from OrbitTransfer | |
OrbitTransfer (OrbitData fromOrbit, OrbitData toOrbit) | |
OrbitTransfer (OrbitData fromOrbit) | |
float | GetDeltaV () |
float | GetDeltaT () |
List< Maneuver > | GetManeuvers () |
override string | ToString () |
Public Attributes | |
double[] | v1 |
double[] | v2 |
Static Public Attributes | |
const int | G_NOT_CONVERGED = 1 |
Error codes. | |
const int | Y_NEGATIVE = 2 |
const int | XFER_180 = 3 |
const int | IMPACT = 4 |
Additional Inherited Members | |
Protected Attributes inherited from OrbitTransfer | |
string | name = "base (error)" |
Name of the transfer (will be over-riden by implementing class. | |
List< Maneuver > | maneuvers |
Maneuvers required to execute the transfer. | |
float | deltaV |
total cost of the manuevers | |
float | deltaT |
OrbitData | fromOrbit |
OrbitData | toOrbit |
NBody | centerBody |
Calculate the universal Lambert transfer. This algorithm allows the transfer to be elliptic or hyperbolic as necessary to meet the designated transfer time. The transfer code can be used to determine the minimum energy transfer between the desired points/orbits - in this case the time of transfer is not specified. Additional API calls can be used to request a specific transfer time. It is frquently useful to obtain the most efficient transfer time and then use this as a baseline from which to investigate the dV cost of faster transfers.
Usage of this class differs from the the other orbit transfer classes. The constructor is used to provide initial details in one of several ways: fromOrbit/toOrbit: use this when the goal is to attain the toOrbit or rendezvous with an object in the toOrbit
fromOrbit/R-to: use when want to get to the specific point R_to
Both constructors will invoke ComputeMinTime() and determine the minimum transfer time. This is then retrieved by: GetTMin()
Calls to ComputeXfer() are then used to calculate the maneuvers required for the specified transfer time.
This algorithm does not provide an answer when the transfer is 180 degrees (Battin is a good alternative in this case).
This algorithm is more general than the Lambert minimum energy solution since it provides the path for a specified time of flight and also the final velocity.
Code adapted from Vallado, Fundamentals of Astrophysics and Applications https://celestrak.com/software/vallado-sw.asp
Setup for Lambert Universal construction. Calculation is done via ComputeXfer and may be done more than once for different transit times.
Initial conditions are passed in when created.
The transfer assumes there is an active NBody at the fromOrbit to be maneuvered to the orbit specified by the toOrbit. If the toOrbit has a NBody, then it is used as the target point, otherwise the phase in the targetOrbit is used to designate a target point. One of the from/to orbit data elements must have a centerNBody.
The time for a minimum energy transfer is computed using the provided value of shortPath.
fromOrbit | |
toOrbit | |
shortPath | Take shortest path along the ellipse (if xfer is an ellipse) |
LambertUniversal.LambertUniversal | ( | OrbitData | _fromOrbit, |
Vector3d | r_from, | ||
Vector3d | r_to, | ||
bool | shortPath | ||
) |
Create a Lambert transfer from a given NBody orbit to a position in physics space.
The constructor will compute the minimum energy transfer to the point taking the shortest path setting into account. The time for the transfer can then be retreived.
_fromOrbit | |
r_from | |
r_to | |
shortPath |
void LambertUniversal.ComputeMinDvSquared | ( | Vector3d | r1_, |
Vector3d | v1_, | ||
Vector3d | r2_, | ||
Vector3d | v2_ | ||
) |
Compute the path from (r1,v1) to (r2,v2) that minimizes the value of (dV)^2. This uses the algorithm developed in "A closed-form solution to the minimum (delta Vtotal)^2 Lambert's Problem" by M. Avendano and D. Mortari, Celest.Mech.Dyn.Ast(2010) 106:25-37.
Note that this solution is not the minimum dV solution but will never exceed it by more than 17% (and for non-aligned r1, r2 is typically very close to the dV solution).
Currently need to exclude transfer requests where angle between r1 and r2 is in range (165, 195) either get excessive dV or no real roots in the solution.
r1 | GE position of the start (not relative to center) |
v1 | GE velocity of the start (not relative to center) |
r2 | GE position of the start (not relative to center) |
v2 | GE velocity of the start (not relative to center) |
int LambertUniversal.ComputeXfer | ( | bool | reverse, |
bool | df, | ||
int | nrev, | ||
double | dtsec | ||
) |
Compute the transfer for the setup via the constructor for the specified transit time dtsec.
This determines the maneuvers requires and places them in the parent classes maneuver list. They can be retrieved by GetManeuvers().
There will be 1 or 2 maneuvers depending on the configuration. If a target orbit is specified and the mode is not intercept then a second maneuver will be used to attain the desired target orbit.
The algorithm used comes from Vallado 4th edition Algorithm 58 (p492).
Note: Unlike the min. energy calculation it does NOT require r1 < r2.
reverse | direction of motion, true for reverse path (long way around) |
df | Controls intial guess, undocumented in Vallado. False seems to work. |
nrev | Number of revolutions until transfer (typically 0) |
dtsec | Required time of flight |
error = 1; // g not converged error = 2; // y negative error = 3; // impossible 180 transfer
error = 4; // trajectory impacts planet radius specified with SetPlanetRadius()
int LambertUniversal.ComputeXferWithPhasing | ( | bool | reverse, |
bool | df, | ||
int | nrev, | ||
double | dtsec, | ||
bool | rendezvous | ||
) |
Determine the Lambert transfer in the specified time to the position that target object will be at in that time. If the rendezvous flag is set, then a maneuver will be generated to match the target. If not set then the ship will intercept the target.
This method requires that the class was created with the constructor that defines toOrbit.
In some cases the transfer trajectory may intersect the central body. This can optionally be checked if the API SetPlanetRadius() is called prior to the use of this method. If the requested trajectory hits the planet an error code 4.
reverse | |
df | |
nrev | |
dtsec | time for the transfer |
rendezvous |
error = 1; // g not converged error = 2; // y negative error = 3; // impossible 180 transfer
error = 4; // trajectory impacts planet radius specified with SetPlanetRadius()
Vector3d LambertUniversal.GetR2 | ( | ) |
Get the final position of the Lambert trajectory. Typically used when doing a xfer with phasing.
void LambertUniversal.SetPlanetRadius | ( | double | radius | ) |
Set the radius of the planet around which transfer is to be computed. This is used when calls to ComputeTransferWithPhasing(). In the event that the requested trajectory hits the planet.
radius |