示例#1
0
        public Form1()
        {

            planet = new Planet(0, 9.81, 67000, new VRageMath.Vector3D(0, 0, 0));

            orbit2 = new Orbit(new VRageMath.Vector3D(100000, 0, 0), new VRageMath.Vector3D(0, planet.GetOrbitalVelocity(100000, (100000 + 100000) / 2), 0), planet);
            orbit = new Orbit(new VRageMath.Vector3D(0, 140000, 0), new VRageMath.Vector3D(-planet.GetOrbitalVelocity(140000, (100000 + 140000) / 2), 0, 0), planet);
            //Console.WriteLine(planet.GetOrbitalVelocity(2000000,1035000));
            epoc = orbit.epoch;
            Console.WriteLine(planet.GetOrbitalVelocity(100000, (100000 + 100000) / 2));
            man = (Maneuver.GetHohmannTransfer (orbit, orbit2, orbit.TrueAnomaly2(0)));

            InitializeComponent();
        }
示例#2
0
        public static Maneuver GetHohmannTransfer(Orbit orbit1,Orbit orbit2,double t) {
            Vector3D pos1;
            Vector3D vel1;
            Vector3D pos2;
            Vector3D vel2;
            double now = 0;
            double deltaV=0;
            double TransferTime = Math.PI * Math.Sqrt(Math.Pow((orbit1.a + orbit2.a), 3) / (8 * orbit1.planet.u));
            double h2 = Math.Sqrt(orbit1.planet.u/Math.Pow(orbit2.a,3));
            double angle = Orbit.RadtoDeg(Math.PI - h2 * TransferTime);
            bool test = true;
            Vector3D dir = new Vector3D(0,0,-1);
            //for (int k = 0; k < 6; k++) {
                if (test == false)
                {
                    //break;
                }
                for (int i = (int)t; i < t + 36000; i++)
                {

                    orbit1.KepToCartAtTrueAnomaly(out pos1, out vel1, Orbit.DegtoRad(i));
                    orbit2.KepToCartAtTrueAnomaly(out pos2, out vel2, Orbit.DegtoRad(i));
                    pos1.Normalize();
                    pos2.Normalize();
                    double ang = Orbit.RadtoDeg(orbit1.GetPhaseAngleTrueAnomaly(orbit2, Orbit.DegtoRad(i)));


                    if (ang <= angle + 1 && ang >= angle - 1)
                    {
                        now = i;
                       // if (k >= 4)
                        //{
                            MatrixD directions = GetDirections(pos1, vel1);
                            dir = Vector3D.Transform(dir, directions);
                       // }
                        orbit1.KepToCartAtTrueAnomaly(out pos1, out vel1, Orbit.DegtoRad(i));
                        orbit2.KepToCart(out pos2, out vel2, orbit1.TimeOfTrueAnomaly(Orbit.DegtoRad(i)) + TransferTime);
                        double r1 = pos1.Length();
                        double r2 = pos2.Length();
                        deltaV = orbit1.planet.GetOrbitalVelocity(r1, (r1 + r2) / 2) - (vel1.Length()); //Math.Sqrt(orbit1.planet.u / r1) * (Math.Sqrt((2 * r2) / (r2 + r1)) - 1);
                        TransferTime = Math.PI * Math.Sqrt(Math.Pow((r1 + r2), 3) / (8 * orbit1.planet.u));
                        angle = Orbit.RadtoDeg(Math.PI - h2 * TransferTime);
                        test = false;
                        break;
                    }

                }
               // }

            //Console.WriteLine(angle + " Found ang");
            Maneuver man = new Maneuver(Orbit.DegtoRad(now), dir, deltaV);
            return man;
            
        }