本文整理汇总了C#中Orbit.SynodicPeriod方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.SynodicPeriod方法的具体用法?C# Orbit.SynodicPeriod怎么用?C# Orbit.SynodicPeriod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orbit
的用法示例。
在下文中一共展示了Orbit.SynodicPeriod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeltaVAndTimeForHohmannTransfer
//Computes the time and dV of a Hohmann transfer injection burn such that at apoapsis the transfer
//orbit passes as close as possible to the target.
//The output burnUT will be the first transfer window found after the given UT.
//Assumes o and target are in approximately the same plane, and orbiting in the same direction.
//Also assumes that o is a perfectly circular orbit (though result should be OK for small eccentricity).
public static Vector3d DeltaVAndTimeForHohmannTransfer(Orbit o, Orbit target, double UT, out double burnUT)
{
double synodicPeriod = o.SynodicPeriod(target);
Vector3d burnDV = Vector3d.zero;
burnUT = UT;
double bestApproachDistance = Double.MaxValue;
double minTime = UT;
double maxTime = UT + 1.1 * synodicPeriod;
int numDivisions = 20;
for (int iter = 0; iter < 8; iter++)
{
double dt = (maxTime - minTime) / numDivisions;
for (int i = 0; i < numDivisions; i++)
{
double t = minTime + i * dt;
Vector3d apsisDirection = -o.SwappedRelativePositionAtUT(t);
double desiredApsis = target.RadiusAtTrueAnomaly(target.TrueAnomalyFromVector(apsisDirection));
double approachDistance;
Vector3d burn;
if (desiredApsis > o.ApR)
{
burn = DeltaVToChangeApoapsis(o, t, desiredApsis);
Orbit transferOrbit = o.PerturbedOrbit(t, burn);
approachDistance = transferOrbit.Separation(target, transferOrbit.NextApoapsisTime(t));
}
else
{
burn = DeltaVToChangePeriapsis(o, t, desiredApsis);
Orbit transferOrbit = o.PerturbedOrbit(t, burn);
approachDistance = transferOrbit.Separation(target, transferOrbit.NextPeriapsisTime(t));
}
if (approachDistance < bestApproachDistance)
{
bestApproachDistance = approachDistance;
burnUT = t;
burnDV = burn;
}
}
minTime = MuUtils.Clamp(burnUT - dt, UT, UT + synodicPeriod);
maxTime = MuUtils.Clamp(burnUT + dt, UT, UT + synodicPeriod);
}
return burnDV;
}
示例2: DeltaVAndTimeForHohmannTransfer
//Computes the time and dV of a Hohmann transfer injection burn such that at apoapsis the transfer
//orbit passes as close as possible to the target.
//The output burnUT will be the first transfer window found after the given UT.
//Assumes o and target are in approximately the same plane, and orbiting in the same direction.
//Also assumes that o is a perfectly circular orbit (though result should be OK for small eccentricity).
public static Vector3d DeltaVAndTimeForHohmannTransfer(Orbit o, Orbit target, double UT, out double burnUT)
{
//We do a binary search for the burn time that zeros out the phase angle between the
//transferring vessel and the target at the apsis of the transfer orbit.
double synodicPeriod = o.SynodicPeriod(target);
double lastApsisPhaseAngle;
Vector3d immediateBurnDV = DeltaVAndApsisPhaseAngleOfHohmannTransfer(o, target, UT, out lastApsisPhaseAngle);
double minTime = UT;
double maxTime = UT + 1.5 * synodicPeriod;
//first find roughly where the zero point is
const int numDivisions = 30;
double dt = (maxTime - minTime) / numDivisions;
for (int i = 1; i <= numDivisions; i++)
{
double t = minTime + dt * i;
double apsisPhaseAngle;
Vector3d dV = DeltaVAndApsisPhaseAngleOfHohmannTransfer(o, target, t, out apsisPhaseAngle);
if ((Math.Abs(apsisPhaseAngle) < 90) && (Math.Sign(lastApsisPhaseAngle) != Math.Sign(apsisPhaseAngle)))
{
minTime = t - dt;
maxTime = t;
break;
}
if ((i == 1) && (Math.Abs(lastApsisPhaseAngle) < 0.5) && (Math.Sign(lastApsisPhaseAngle) == Math.Sign(apsisPhaseAngle)))
{
//In this case we are JUST passed the center of the transfer window, but probably we
//can still do the transfer just fine. Don't do a search, just return an immediate burn
burnUT = UT;
return immediateBurnDV;
}
lastApsisPhaseAngle = apsisPhaseAngle;
if (i == numDivisions)
{
throw new ArgumentException("OrbitalManeuverCalculator.DeltaVAndTimeForHohmannTransfer: couldn't find the transfer window!!");
}
}
int minTimeApsisPhaseAngleSign = Math.Sign(lastApsisPhaseAngle);
//then do a binary search
while (maxTime - minTime > 0.01)
{
double testTime = (maxTime + minTime) / 2;
double testApsisPhaseAngle;
Vector3d dV = DeltaVAndApsisPhaseAngleOfHohmannTransfer(o, target, testTime, out testApsisPhaseAngle);
if (Math.Sign(testApsisPhaseAngle) == minTimeApsisPhaseAngleSign)
{
minTime = testTime;
}
else
{
maxTime = testTime;
}
}
burnUT = (minTime + maxTime) / 2;
double finalApsisPhaseAngle;
Vector3d burnDV = DeltaVAndApsisPhaseAngleOfHohmannTransfer(o, target, burnUT, out finalApsisPhaseAngle);
return burnDV;
}