Beispiel #1
0
        void update()
        {
            if (TransferTime < 0)
            {
                TrajectoryCalculator.ClosestApproach(Orbit, TargetOrbit, StartUT, VSL.Geometry.MinDistance, out AtTargetUT);
                TransferTime = AtTargetUT - StartUT;
            }
            else
            {
                AtTargetUT = StartUT + TransferTime;
            }
            AtTargetPos      = Orbit.getRelativePositionAtUT(AtTargetUT);
            AtTargetVel      = Orbit.getOrbitalVelocityAtUT(AtTargetUT);
            TargetPos        = TargetOrbit.getRelativePositionAtUT(AtTargetUT);
            DistanceToTarget = Utils.ClampL((AtTargetPos - TargetPos).magnitude - VSL.Geometry.MinDistance, 0);
            DeltaTA          = Utils.ProjectionAngle(AtTargetPos, TargetPos,
                                                     Vector3d.Cross(Orbit.GetOrbitNormal(), AtTargetPos)) *
                               Math.Sign(TargetOrbit.period - OrigOrbit.period);
            DeltaFi = TrajectoryCalculator.RelativeInclination(Orbit, TargetPos);
            DeltaR  = Vector3d.Dot(TargetPos - AtTargetPos, AtTargetPos.normalized);
            var t_orbit = Target.GetOrbit();
            var t_vel   = t_orbit != null?t_orbit.getOrbitalVelocityAtUT(AtTargetUT) : Vector3d.zero;

            BrakeDeltaV   = t_vel - Orbit.getOrbitalVelocityAtUT(AtTargetUT);
            BrakeDuration = VSL.Engines.TTB((float)BrakeDeltaV.magnitude);
            KillerOrbit   = Orbit.PeR < MinPeR && Orbit.timeToPe < TransferTime;
//            Utils.Log("{}", this);//debug
        }
        void update()
        {
            if (TransferTime < 0)
            {
                TrajectoryCalculator.ClosestApproach(Orbit, TargetOrbit, StartUT, VSL.Geometry.MinDistance, out AtTargetUT);
                TransferTime = AtTargetUT - StartUT;
            }
            else
            {
                AtTargetUT = StartUT + TransferTime;
            }
            var obt     = TrajectoryCalculator.NextOrbit(Orbit, AtTargetUT);
            var t_orbit = TrajectoryCalculator.NextOrbit(TargetOrbit, AtTargetUT);

            AtTargetPos      = obt.getRelativePositionAtUT(AtTargetUT);
            AtTargetVel      = obt.getOrbitalVelocityAtUT(AtTargetUT);
            TargetPos        = TrajectoryCalculator.RelativePosAtUT(obt.referenceBody, t_orbit, AtTargetUT);
            AtTargetRelPos   = AtTargetPos - TargetPos;
            DistanceToTarget = AtTargetRelPos.magnitude - VSL.Geometry.MinDistance;
            DirectHit        = DistanceToTarget < 1;
            DistanceToTarget = Utils.ClampL(DistanceToTarget, 0);
            BrakeDeltaV      = t_orbit.GetFrameVelAtUT(AtTargetUT) - obt.GetFrameVelAtUT(AtTargetUT);
            var brake_dV = (float)BrakeDeltaV.magnitude;

            BrakeDuration = VSL.Engines.TTB_Precise(brake_dV);
            BrakeFuel     = VSL.Engines.FuelNeeded(brake_dV);
            FullBrake     = GetTotalFuel() < VSL.Engines.AvailableFuelMass;
            //check if this trajectory is too close to any of celestial bodies it passes by
            KillerOrbit = TransferTime < BrakeDuration + ManeuverDuration;
            update_killer(OrigOrbit, StartUT);
            update_killer(Orbit, AtTargetUT);
//            Utils.Log("{}", this);//debug
        }
        void update()
        {
            if (TransferTime < 0)
            {
                TrajectoryCalculator.ClosestApproach(Orbit, TargetOrbit, StartUT, out AtTargetUT);
                TransferTime = AtTargetUT - StartUT;
            }
            else
            {
                AtTargetUT = StartUT + TransferTime;
            }
            AtTargetPos      = Orbit.getRelativePositionAtUT(AtTargetUT);
            AtTargetVel      = Orbit.getOrbitalVelocityAtUT(AtTargetUT);
            TargetPos        = TargetOrbit.getRelativePositionAtUT(AtTargetUT);
            DistanceToTarget = Utils.ClampL((AtTargetPos - TargetPos).magnitude - VSL.Geometry.R - TargetVessel.Radius(), 0);
            DeltaTA          = Utils.ProjectionAngle(AtTargetPos, TargetPos,
                                                     Vector3d.Cross(Orbit.GetOrbitNormal(), AtTargetPos)) *
                               Math.Sign(TargetOrbit.period - OrigOrbit.period);
            DeltaFi     = TrajectoryCalculator.RelativeInclination(Orbit, TargetPos);
            DeltaR      = Vector3d.Dot(TargetPos - AtTargetPos, AtTargetPos.normalized);
            KillerOrbit = Orbit.PeR < MinPeR && Orbit.timeToPe < TransferTime;
//			DebugUtils.Log("{}", this);//debug
        }
        bool StartCondition(float dV)
        {
            if (Working)
            {
                return(true);
            }
            if (!CFG.AP1[Autopilot1.MatchVelNear])
            {
                return(true);
            }
            //calculate time to nearest approach
            double ApprUT;
            var    tOrb = Target.GetOrbit();

            TrajectoryCalculator.ClosestApproach(VSL.orbit, tOrb, VSL.Physics.UT, out ApprUT);
            TTA = (float)(ApprUT - VSL.Physics.UT);
            var ApprdV = (VSL.orbit.getOrbitalVelocityAtUT(ApprUT) - tOrb.getOrbitalVelocityAtUT(ApprUT)).xzy;

            dV = (float)ApprdV.magnitude;
            CFG.AT.OnIfNot(Attitude.Custom);
            ATC.SetThrustDirW(ApprdV);
            if (TTA > 0)
            {
                VSL.Info.Countdown = TTA - BrakingOffset(dV, VSL, out VSL.Info.TTB);
                if (VSL.Controls.CanWarp)
                {
                    VSL.Controls.WarpToTime = VSL.Physics.UT + VSL.Info.Countdown - VSL.Controls.MinAlignmentTime;
                }
                if (VSL.Info.Countdown > 0)
                {
                    return(false);
                }
            }
            VSL.Info.Countdown = 0;
            Working            = true;
            return(true);
        }