本文整理汇总了C#中Orbit.Prograde方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.Prograde方法的具体用法?C# Orbit.Prograde怎么用?C# Orbit.Prograde使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orbit
的用法示例。
在下文中一共展示了Orbit.Prograde方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeltaVToChangeApoapsis
//Computes the delta-V of the burn at a given UT required to change an orbits apoapsis to a given value.
//The computed burn is always prograde or retrograde, though this may not be strictly optimal.
//Note that you can pass in a negative apoapsis if the desired final orbit is hyperbolic
public static Vector3d DeltaVToChangeApoapsis(Orbit o, double UT, double newApR)
{
double radius = o.Radius(UT);
//sanitize input
if (newApR > 0) newApR = Math.Max(newApR, radius + 1);
//are we raising or lowering the periapsis?
bool raising = ApoapsisIsHigher(newApR, o.ApR);
Vector3d burnDirection = (raising ? 1 : -1) * o.Prograde(UT);
double minDeltaV = 0;
double maxDeltaV;
if (raising)
{
//put an upper bound on the required deltaV:
maxDeltaV = 0.25;
double ap = o.ApR;
while (ApoapsisIsHigher(newApR, ap))
{
maxDeltaV *= 2;
ap = o.PerturbedOrbit(UT, maxDeltaV * burnDirection).ApR;
if (maxDeltaV > 100000) break; //a safety precaution
}
}
else
{
//when lowering apoapsis, we burn retrograde, and max possible deltaV is total velocity
maxDeltaV = o.SwappedOrbitalVelocityAtUT(UT).magnitude;
}
//now do a binary search to find the needed delta-v
while (maxDeltaV - minDeltaV > 0.01)
{
double testDeltaV = (maxDeltaV + minDeltaV) / 2.0;
double testApoapsis = o.PerturbedOrbit(UT, testDeltaV * burnDirection).ApR;
bool above = ApoapsisIsHigher(testApoapsis, newApR);
if ((raising && above) || (!raising && !above))
{
maxDeltaV = testDeltaV;
}
else
{
minDeltaV = testDeltaV;
}
}
return ((maxDeltaV + minDeltaV) / 2) * burnDirection;
}
示例2: DeltaVForSemiMajorAxis
public static Vector3d DeltaVForSemiMajorAxis(Orbit o, double UT, double newSMA)
{
bool raising = o.semiMajorAxis < newSMA;
Vector3d burnDirection = (raising ? 1 : -1) * o.Prograde(UT);
double minDeltaV = 0;
double maxDeltaV;
if (raising)
{
//put an upper bound on the required deltaV:
maxDeltaV = 0.25;
while (o.PerturbedOrbit(UT, maxDeltaV * burnDirection).semiMajorAxis < newSMA)
{
maxDeltaV *= 2;
if (maxDeltaV > 100000)
break; //a safety precaution
}
}
else
{
//when lowering the SMA, we burn horizontally, and max possible deltaV is the deltaV required to kill all horizontal velocity
maxDeltaV = Math.Abs(Vector3d.Dot(o.SwappedOrbitalVelocityAtUT(UT), burnDirection));
}
// Debug.Log (String.Format ("We are {0} SMA to {1}", raising ? "raising" : "lowering", newSMA));
// Debug.Log (String.Format ("Starting SMA iteration with maxDeltaV of {0}", maxDeltaV));
//now do a binary search to find the needed delta-v
while (maxDeltaV - minDeltaV > 0.01)
{
double testDeltaV = (maxDeltaV + minDeltaV) / 2.0;
double testSMA = o.PerturbedOrbit(UT, testDeltaV * burnDirection).semiMajorAxis;
// Debug.Log (String.Format ("Testing dV of {0} gave an SMA of {1}", testDeltaV, testSMA));
if ((testSMA < 0) || (testSMA > newSMA && raising) || (testSMA < newSMA && !raising))
{
maxDeltaV = testDeltaV;
}
else
{
minDeltaV = testDeltaV;
}
}
return ((maxDeltaV + minDeltaV) / 2) * burnDirection;
}