本文整理汇总了C#中Orbit.Horizontal方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.Horizontal方法的具体用法?C# Orbit.Horizontal怎么用?C# Orbit.Horizontal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orbit
的用法示例。
在下文中一共展示了Orbit.Horizontal方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeltaVToChangePeriapsis
//Computes the delta-V of the burn required to attain a given periapsis, starting from
//a given orbit and burning at a given UT. Throws an ArgumentException if given an impossible periapsis.
//The computed burn is always horizontal, though this may not be strictly optimal.
public static Vector3d DeltaVToChangePeriapsis(Orbit o, double UT, double newPeR)
{
double radius = o.Radius(UT);
//sanitize input
newPeR = MuUtils.Clamp(newPeR, 0 + 1, radius - 1);
//are we raising or lowering the periapsis?
bool raising = (newPeR > o.PeR);
Vector3d burnDirection = (raising ? 1 : -1) * o.Horizontal(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).PeR < newPeR)
{
maxDeltaV *= 2;
if (maxDeltaV > 100000) break; //a safety precaution
}
}
else
{
//when lowering periapsis, 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));
}
//now do a binary search to find the needed delta-v
while (maxDeltaV - minDeltaV > 0.01)
{
double testDeltaV = (maxDeltaV + minDeltaV) / 2.0;
double testPeriapsis = o.PerturbedOrbit(UT, testDeltaV * burnDirection).PeR;
if ((testPeriapsis > newPeR && raising) || (testPeriapsis < newPeR && !raising))
{
maxDeltaV = testDeltaV;
}
else
{
minDeltaV = testDeltaV;
}
}
return ((maxDeltaV + minDeltaV) / 2) * burnDirection;
}
示例2: DeltaVToEllipticize
//Computes the deltaV of the burn needed to set a given PeR and ApR at at a given UT.
public static Vector3d DeltaVToEllipticize(Orbit o, double UT, double newPeR, double newApR)
{
double radius = o.Radius(UT);
//sanitize inputs
newPeR = MuUtils.Clamp(newPeR, 0 + 1, radius - 1);
newApR = Math.Max(newApR, radius + 1);
double GM = o.referenceBody.gravParameter;
double E = -GM / (newPeR + newApR); //total energy per unit mass of new orbit
double L = Math.Sqrt(Math.Abs((Math.Pow(E * (newApR - newPeR), 2) - GM * GM) / (2 * E))); //angular momentum per unit mass of new orbit
double kineticE = E + GM / radius; //kinetic energy (per unit mass) of new orbit at UT
double horizontalV = L / radius; //horizontal velocity of new orbit at UT
double verticalV = Math.Sqrt(Math.Abs(2 * kineticE - horizontalV * horizontalV)); //vertical velocity of new orbit at UT
Vector3d actualVelocity = o.SwappedOrbitalVelocityAtUT(UT);
//untested:
verticalV *= Math.Sign(Vector3d.Dot(o.Up(UT), actualVelocity));
Vector3d desiredVelocity = horizontalV * o.Horizontal(UT) + verticalV * o.Up(UT);
return desiredVelocity - actualVelocity;
}
示例3: DeltaVToCircularize
//Computes the deltaV of the burn needed to circularize an orbit at a given UT.
public static Vector3d DeltaVToCircularize(Orbit o, double UT)
{
Vector3d desiredVelocity = CircularOrbitSpeed(o.referenceBody, o.Radius(UT)) * o.Horizontal(UT);
Vector3d actualVelocity = o.SwappedOrbitalVelocityAtUT(UT);
return desiredVelocity - actualVelocity;
}