Beispiel #1
0
        RendezvousTrajectory new_trajectory(double StartUT, double transfer_time)
        {
            var solver = new LambertSolver(VesselOrbit, TargetOrbit.getRelativePositionAtUT(StartUT + transfer_time), StartUT);
            var dV     = solver.dV4Transfer(transfer_time);

            return(new RendezvousTrajectory(VSL, dV, StartUT, CFG.Target, MinPeR, transfer_time));
        }
        protected override bool check_target()
        {
            if (!base.check_target())
            {
                return(false);
            }
            if (VesselOrbit.PeR > Body.Radius)
            {
                Status("yellow", "Cannot perform <b>Ballistic Jump</b> from orbit.\n" +
                       "Use <b>Land at Target</b> instead.");
                return(false);
            }
            //compute initial orbit estimation using LambertSolver
            var solver = new LambertSolver(VesselOrbit, CFG.Target.RelOrbPos(Body), VSL.Physics.UT);
            var dV     = solver.dV4TransferME();

            if (Vector3d.Dot(VesselOrbit.vel + dV, VesselOrbit.pos) < 0)
            {
                dV = -2 * VesselOrbit.vel - dV;
            }
            var trj = new LandingTrajectory(VSL, dV, VSL.Physics.UT, CFG.Target, TargetAltitude, false);

            if (trj.TransferTime < TRJ.ManeuverOffset)
            {
                Status("yellow", "The target is too close for the jump.\n" +
                       "Use <b>Go To</b> instead.");
                return(false);
            }
            return(true);
        }
        void compute_initial_trajectory()
        {
            trajectory    = null;
            MAN.MinDeltaV = 1f;
            stage         = Stage.Compute;
            var tPos   = CFG.Target.RelOrbPos(Body);
            var solver = new LambertSolver(VesselOrbit, tPos + tPos.normalized * LTRJ.FlyOverAlt, VSL.Physics.UT);
            var vel    = (VesselOrbit.vel + solver.dV4TransferME());

            if (Vector3d.Dot(vel, VesselOrbit.pos) < 0)
            {
                vel = -vel;
            }
            var dir = vel.normalized;
            var V   = vel.magnitude;

                        #if DEBUG
            if (!ME_orbit)
            {
                dir = (VSL.Physics.Up +
                       Vector3d.Exclude(VSL.Physics.Up, vel).normalized *
                       BJ.StartTangent *(1 + CFG.Target.AngleTo(VSL) / Utils.TwoPI) * BJ.InclinationF).normalized.xzy;
            }
                        #endif
            setup_calculation((o, b) => fixed_inclination_orbit(o, b, ref dir, ref V, BJ.StartOffset));
        }
        void start_orbit()
        {
            ToOrbit = null;
            var dV      = Vector3d.zero;
            var old     = VesselOrbit;
            var StartUT = VSL.Physics.UT + CorrectionOffset;

            CFG.BR.OffIfOn(BearingMode.Auto);
            update_trajectory();
            if (VesselOrbit.PeR < MinPeR)
            {
                StartUT = Math.Min(trajectory.AtTargetUT, VSL.Physics.UT + (VesselOrbit.ApAhead()? VesselOrbit.timeToAp : CorrectionOffset));
                if (trajectory.DistanceToTarget < REN.ApproachThreshold * 2 && StartUT.Equals(trajectory.AtTargetUT))
                {                 //approach is close enough to directly match orbits
                    match_orbits();
                    return;
                }
                var transfer_time = Utils.ClampL(TargetOrbit.period * (0.25 - AngleDelta(VesselOrbit, TargetOrbit, StartUT) / 360), 1);
                var solver        = new LambertSolver(VesselOrbit, TargetOrbit.getRelativePositionAtUT(StartUT + transfer_time), StartUT);
                dV = solver.dV4Transfer(transfer_time);
                var trj = new RendezvousTrajectory(VSL, dV, StartUT, CFG.Target, MinPeR, transfer_time);
                if (!dV.IsZero() && !trj.KillerOrbit)
                {                 //approach orbit is possible
                    compute_start_orbit(StartUT);
                    return;
                }
                //starting from circular orbit and proceeding to TTR fitting...
                StartUT = VesselOrbit.ApAhead()? VSL.Physics.UT + VesselOrbit.timeToAp : VSL.Physics.UT + CorrectionOffset;
                dV      = dV4C(old, hV(StartUT), StartUT);
                old     = NewOrbit(old, dV, StartUT);
            }
            else if (trajectory.RelDistanceToTarget < REN.CorrectionStart || TargetLoaded)
            {
                if (trajectory.RelDistanceToTarget > REN.CorrectionStart / 4 && !TargetLoaded)
                {
                    fine_tune_approach();
                }
                else
                {
                    match_orbits();
                }
                return;
            }
            //compute orbit with desired TTR and activate maneuver autopilot
            dV += dV4TTR(old, TargetOrbit, REN.MaxTTR, REN.MaxDeltaV, MinPeR, StartUT);
            if (!dV.IsZero())
            {
                add_node(dV, StartUT);
                CFG.AP1.On(Autopilot1.Maneuver);
            }
            stage = Stage.StartOrbit;
        }
        RendezvousTrajectory new_trajectory(double StartUT, double transfer_time)
        {
            var endUT  = StartUT + transfer_time;
            var solver = new LambertSolver(NextOrbit(endUT), NextOrbit(TargetOrbit, endUT).getRelativePositionAtUT(endUT), StartUT);

            if (solver.NotElliptic(transfer_time))
            {
                transfer_time = solver.ParabolicTime + 1;
            }
            var dV = solver.dV4Transfer(transfer_time);

            return(new RendezvousTrajectory(VSL, dV, StartUT, CFG.Target, MinPeR, transfer_time));
        }
Beispiel #6
0
        Vector3d compute_intial_jump_velocity()
        {
            var tPos   = CFG.Target.OrbPos(Body);
            var solver = new LambertSolver(VesselOrbit, tPos + tPos.normalized * LTRJ.FlyOverAlt, VSL.Physics.UT);
            var vel    = VesselOrbit.vel +
                         solver.dV4TransferME()
                         .ClampMagnitudeH(Math.Sqrt(Body.gMagnitudeAtCenter / VesselOrbit.radius));

            if (Vector3d.Dot(vel, VesselOrbit.pos) < 0)
            {
                vel = -vel;
            }
            //correcto for low trajectories
            var ascention_angle = 90 - Utils.Angle2(vel, VesselOrbit.pos);

            if (ascention_angle < BJ.MinStartAngle)
            {
                vel = QuaternionD.AngleAxis(BJ.MinStartAngle - ascention_angle, Vector3d.Cross(vel, VesselOrbit.pos)) * vel;
            }
            return(vel);
        }