Exemplo n.º 1
0
 public double TargetTimeToClosestApproach()
 {
     if (core.target.Target != null && core.vesselState.altitudeTrue < 1000.0)
     {
         return(GuiUtils.FromToETA(core.vessel.CoM, core.target.Transform.position));
     }
     if (!core.target.NormalTargetExists)
     {
         return(double.NaN);
     }
     if (core.target.TargetOrbit.referenceBody != this.scriptModule.orbit.referenceBody)
     {
         return(double.NaN);
     }
     if (double.IsNaN(core.target.TargetOrbit.semiMajorAxis))
     {
         return(double.NaN);
     }
     if (core.vesselState.altitudeTrue < 1000.0)
     {
         double a   = (core.vessel.mainBody.transform.position - core.vessel.transform.position).magnitude;
         double b   = (core.vessel.mainBody.transform.position - core.target.Transform.position).magnitude;
         double c   = Vector3d.Distance(core.vessel.transform.position, core.target.Position);
         double ang = Math.Acos(((a * a + b * b) - c * c) / (double)(2f * a * b));
         return(ang * core.vessel.mainBody.Radius / core.vesselState.speedSurfaceHorizontal);
     }
     return(this.scriptModule.orbit.NextClosestApproachTime(core.target.TargetOrbit, core.vesselState.time) - core.vesselState.time);
 }
Exemplo n.º 2
0
 public string TargetTimeToClosestApproach()
 {
     if (core.target.Target != null && vesselState.altitudeTrue < 1000.0)
     {
         return(GuiUtils.TimeToDHMS(GuiUtils.FromToETA(vessel.CoM, core.target.Transform.position)));
     }
     if (!core.target.NormalTargetExists)
     {
         return("N/A");
     }
     if (vesselState.altitudeTrue < 1000.0)
     {
         double a   = (vessel.mainBody.transform.position - vessel.transform.position).magnitude;
         double b   = (vessel.mainBody.transform.position - core.target.Transform.position).magnitude;
         double c   = Vector3d.Distance(vessel.transform.position, core.target.Position);
         double ang = Math.Acos(((a * a + b * b) - c * c) / (double)(2f * a * b));
         return(GuiUtils.TimeToDHMS(ang * vessel.mainBody.Radius / vesselState.speedSurfaceHorizontal));
     }
     if (!core.target.NormalTargetExists)
     {
         return("N/A");
     }
     if (vesselState.altitudeTrue < 1000.0)
     {
         double a   = (vessel.mainBody.transform.position - vessel.transform.position).magnitude;
         double b   = (vessel.mainBody.transform.position - core.target.Transform.position).magnitude;
         double c   = Vector3d.Distance(vessel.transform.position, core.target.Position);
         double ang = Math.Acos(((a * a + b * b) - c * c) / (double)(2f * a * b));
         return(GuiUtils.TimeToDHMS(ang * vessel.mainBody.Radius / vesselState.speedSurfaceHorizontal));
     }
     if (core.target.TargetOrbit.referenceBody != orbit.referenceBody)
     {
         return("N/A");
     }
     return(GuiUtils.TimeToDHMS(orbit.NextClosestApproachTime(core.target.TargetOrbit, vesselState.time) - vesselState.time));
 }