本文整理汇总了C#中Orbit.NextClosestApproachTime方法的典型用法代码示例。如果您正苦于以下问题:C# Orbit.NextClosestApproachTime方法的具体用法?C# Orbit.NextClosestApproachTime怎么用?C# Orbit.NextClosestApproachTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orbit
的用法示例。
在下文中一共展示了Orbit.NextClosestApproachTime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MakeNodeImpl
public override ManeuverParameters MakeNodeImpl(Orbit o, double UT, MechJebModuleTargetController target)
{
if (!target.NormalTargetExists)
throw new OperationException("must select a target for the course correction.");
Orbit correctionPatch = o;
while (correctionPatch != null)
{
if (correctionPatch.referenceBody == target.TargetOrbit.referenceBody)
{
o = correctionPatch;
UT = correctionPatch.StartUT;
break;
}
correctionPatch = target.core.vessel.GetNextPatch(correctionPatch);
}
if (correctionPatch == null || correctionPatch.referenceBody != target.TargetOrbit.referenceBody)
throw new OperationException("target for course correction must be in the same sphere of influence");
if (o.NextClosestApproachTime(target.TargetOrbit, UT) < UT + 1 ||
o.NextClosestApproachDistance(target.TargetOrbit, UT) > target.TargetOrbit.semiMajorAxis * 0.2)
{
errorMessage = "Warning: orbit before course correction doesn't seem to approach target very closely. Planned course correction may be extreme. Recommend plotting an approximate intercept orbit and then plotting a course correction.";
}
CelestialBody targetBody = target.Target as CelestialBody;
Vector3d dV = targetBody != null ?
OrbitalManeuverCalculator.DeltaVAndTimeForCheapestCourseCorrection(o, UT, target.TargetOrbit, targetBody, targetBody.Radius + courseCorrectFinalPeA, out UT):
OrbitalManeuverCalculator.DeltaVAndTimeForCheapestCourseCorrection(o, UT, target.TargetOrbit, interceptDistance, out UT);
return new ManeuverParameters(dV, UT);
}
示例2: DeltaVAndTimeForCheapestCourseCorrection
public static Vector3d DeltaVAndTimeForCheapestCourseCorrection(Orbit o, double UT, Orbit target, out double burnUT)
{
double closestApproachTime = o.NextClosestApproachTime(target, UT + 2); //+2 so that closestApproachTime is definitely > UT
burnUT = UT;
Vector3d dV = DeltaVToInterceptAtTime(o, burnUT, target, closestApproachTime);
int fineness = 20;
for (double step = 0.5; step < fineness; step += 1.0)
{
double testUT = UT + (closestApproachTime - UT) * step / fineness;
Vector3d testDV = DeltaVToInterceptAtTime(o, testUT, target, closestApproachTime);
if (testDV.magnitude < dV.magnitude)
{
dV = testDV;
burnUT = testUT;
}
}
return dV;
}
示例3: DeltaVForCourseCorrection
//First finds the time of closest approach to the target during the next orbit after the
//time UT. Then returns the delta-V of a burn at UT that will change the separation at
//that closest approach time to zero.
//This will likely only return sensible results when the given orbit is already an
//approximate intercept trajectory.
public static Vector3d DeltaVForCourseCorrection(Orbit o, double UT, Orbit target)
{
double closestApproachTime = o.NextClosestApproachTime(target, UT + 1); //+1 so that closestApproachTime is definitely > UT
Vector3d dV = DeltaVToInterceptAtTime(o, UT, target, closestApproachTime);
return dV;
}
示例4: ComputeManeuverTime
public double ComputeManeuverTime(Orbit o, double UT, MechJebModuleTargetController target)
{
switch (allowedTimeRef[currentTimeRef])
{
case TimeReference.X_FROM_NOW:
UT += leadTime.val;
break;
case TimeReference.APOAPSIS:
if (o.eccentricity < 1)
{
UT = o.NextApoapsisTime(UT);
}
else
{
throw new OperationException("Warning: orbit is hyperbolic, so apoapsis doesn't exist.");
}
break;
case TimeReference.PERIAPSIS:
UT = o.NextPeriapsisTime(UT);
break;
case TimeReference.CLOSEST_APPROACH:
if (target.NormalTargetExists)
{
UT = o.NextClosestApproachTime(target.TargetOrbit, UT);
}
else
{
throw new OperationException("Warning: no target selected.");
}
break;
case TimeReference.ALTITUDE:
if (circularizeAltitude > o.PeA && (circularizeAltitude < o.ApA || o.eccentricity >= 1))
{
UT = o.NextTimeOfRadius(UT, o.referenceBody.Radius + circularizeAltitude);
}
else
{
throw new OperationException("Warning: can't circularize at this altitude, since current orbit does not reach it.");
}
break;
case TimeReference.EQ_ASCENDING:
if (o.AscendingNodeEquatorialExists())
{
UT = o.TimeOfAscendingNodeEquatorial(UT);
}
else
{
throw new OperationException("Warning: equatorial ascending node doesn't exist.");
}
break;
case TimeReference.EQ_DESCENDING:
if (o.DescendingNodeEquatorialExists())
{
UT = o.TimeOfDescendingNodeEquatorial(UT);
}
else
{
throw new OperationException("Warning: equatorial descending node doesn't exist.");
}
break;
case TimeReference.EQ_NEAREST_AD:
if(o.AscendingNodeEquatorialExists())
{
UT = o.DescendingNodeEquatorialExists()
? System.Math.Min(o.TimeOfAscendingNodeEquatorial(UT), o.TimeOfDescendingNodeEquatorial(UT))
: o.TimeOfAscendingNodeEquatorial(UT);
}
else if(o.DescendingNodeEquatorialExists())
{
UT = o.TimeOfDescendingNodeEquatorial(UT);
}
else
{
throw new OperationException("Warning: neither ascending nor descending node exists.");
}
break;
case TimeReference.EQ_HIGHEST_AD:
if(o.AscendingNodeEquatorialExists())
{
if(o.DescendingNodeEquatorialExists())
{
var anTime = o.TimeOfAscendingNodeEquatorial(UT);
var dnTime = o.TimeOfDescendingNodeEquatorial(UT);
UT = o.getOrbitalVelocityAtUT(anTime).magnitude <= o.getOrbitalVelocityAtUT(dnTime).magnitude
? anTime
: dnTime;
}
else
{
UT = o.TimeOfAscendingNodeEquatorial(UT);
}
}
//.........这里部分代码省略.........
示例5: CheckPreconditions
//.........这里部分代码省略.........
errorMessage = "target for Hohmann transfer must be in the same sphere of influence.";
}
else if (o.eccentricity > 1)
{
error = true;
errorMessage = "starting orbit for Hohmann transfer must not be hyperbolic.";
}
else if (core.target.Orbit.eccentricity > 1)
{
error = true;
errorMessage = "target orbit for Hohmann transfer must not be hyperbolic.";
}
else if (o.RelativeInclination(core.target.Orbit) > 30 && o.RelativeInclination(core.target.Orbit) < 150)
{
errorMessage = "Warning: target's orbital plane is at a " + o.RelativeInclination(core.target.Orbit).ToString("F0") + "º angle to starting orbit's plane (recommend at most 30º). Planned transfer may not intercept target properly.";
}
else if (o.eccentricity > 0.2)
{
errorMessage = "Warning: Recommend starting Hohmann transfers from a near-circular orbit (eccentricity < 0.2). Planned transfer is starting from an orbit with eccentricity " + o.eccentricity.ToString("F2") + " and so may not intercept target properly.";
}
break;
case Operation.COURSE_CORRECTION:
if (!core.target.NormalTargetExists)
{
error = true;
errorMessage = "must select a target for the course correction.";
}
else if (o.referenceBody != core.target.Orbit.referenceBody)
{
error = true;
errorMessage = "target for course correction must be in the same sphere of influence";
}
else if (o.NextClosestApproachTime(core.target.Orbit, UT) < UT + 1 ||
o.NextClosestApproachDistance(core.target.Orbit, UT) > core.target.Orbit.semiMajorAxis * 0.2)
{
errorMessage = "Warning: orbit before course correction doesn't seem to approach target very closely. Planned course correction may be extreme. Recommend plotting an approximate intercept orbit and then plotting a course correction.";
}
break;
case Operation.INTERPLANETARY_TRANSFER:
if (!core.target.NormalTargetExists)
{
error = true;
errorMessage = "must select a target for the interplanetary transfer.";
}
else if (o.referenceBody.referenceBody == null)
{
error = true;
errorMessage = "doesn't make sense to plot an interplanetary transfer from an orbit around " + o.referenceBody.theName + ".";
}
else if (o.referenceBody.referenceBody != core.target.Orbit.referenceBody)
{
error = true;
if (o.referenceBody == core.target.Orbit.referenceBody) errorMessage = "use regular Hohmann transfer function to intercept another body orbiting " + o.referenceBody.theName + ".";
else errorMessage = "an interplanetary transfer from within " + o.referenceBody.theName + "'s sphere of influence must target a body that orbits " + o.referenceBody.theName + "'s parent, " + o.referenceBody.referenceBody.theName + ".";
}
else if (o.referenceBody.orbit.RelativeInclination(core.target.Orbit) > 30)
{
errorMessage = "Warning: target's orbital plane is at a " + o.RelativeInclination(core.target.Orbit).ToString("F0") + "º angle to " + o.referenceBody.theName + "'s orbital plane (recommend at most 30º). Planned interplanetary transfer may not intercept target properly.";
}
else
{
double relativeInclination = Vector3d.Angle(o.SwappedOrbitNormal(), o.referenceBody.orbit.SwappedOrbitNormal());
if (relativeInclination > 10)
{