Example #1
0
        void CalcLambertDVs(double t0, double dt, out Vector3d exitDV, out Vector3d captureDV)
        {
            double        t1            = t0 + dt;
            CelestialBody origin_planet = origin.referenceBody;

            Vector3d V1_0 = origin_planet.orbit.getOrbitalVelocityAtUT(t0);
            Vector3d R1   = origin_planet.orbit.getRelativePositionAtUT(t0);

            Vector3d R2   = destination.getRelativePositionAtUT(t1);
            Vector3d V2_1 = destination.getOrbitalVelocityAtUT(t1);

            Vector3d V1 = V1_0;
            Vector3d V2 = V2_1;

            try {
                GoodingSolver.Solve(origin_planet.referenceBody.gravParameter, R1, V1_0, R2, V2_1, dt, 0, out V1, out V2);
            }
            catch (Exception) {}

            exitDV    = V1 - V1_0;
            captureDV = V2_1 - V2;
        }
Example #2
0
        void ComputeDeltaV(object args)
        {
            CelestialBody origin_planet = origin.referenceBody;

            for (int date_index = TakeDateIndex();
                 date_index >= 0;
                 date_index = TakeDateIndex())
            {
                double t0 = DateFromIndex(date_index);

                if (double.IsInfinity(t0))
                {
                    continue;
                }

                Vector3d V1_0 = origin_planet.orbit.getOrbitalVelocityAtUT(t0);
                Vector3d R1   = origin_planet.orbit.getRelativePositionAtUT(t0);

                int duration_samples = DurationSamplesForDate(date_index);
                for (int duration_index = 0; duration_index < duration_samples; duration_index++)
                {
                    if (stop)
                    {
                        break;
                    }

                    double dt = DurationFromIndex(duration_index);
                    double t1 = t0 + dt;

                    Vector3d R2   = destination.getRelativePositionAtUT(t1);
                    Vector3d V2_1 = destination.getOrbitalVelocityAtUT(t1);

                    /* bool short_way = Vector3d.Dot(Vector3d.Cross(R1, R2), origin_planet.orbit.GetOrbitNormal()) > 0; */
                    try
                    {
                        Vector3d V1, V2;
#if DEBUG
                        log[date_index, duration_index] = dt + ","
                                                          + R1.x + "," + R1.y + "," + R1.z + ","
                                                          + R2.x + "," + R2.y + "," + R2.z + ","
                                                          + V1_0.x + "," + V1_0.y + "," + V1_0.z;
#endif
                        /* LambertSolver.Solve(R1, R2, dt, origin_planet.referenceBody, short_way, out V1, out V2); */
                        GoodingSolver.Solve(R1, V1_0, R2, V2_1, dt, origin_planet.referenceBody, 0, out V1, out V2);

#if DEBUG
                        log[date_index, duration_index] += "," + V1.x + "," + V1.y + "," + V1.z;
#endif

                        Vector3d soi_exit_velocity = V1 - V1_0;
                        var      maneuver          = ComputeEjectionManeuver(soi_exit_velocity, origin, t0);
                        if (!double.IsNaN(maneuver.dV.sqrMagnitude) && !double.IsNaN(maneuver.UT))
                        {
                            computed[date_index, duration_index] = maneuver;
                        }
#if DEBUG
                        log[date_index, duration_index] += "," + maneuver.dV.magnitude;
#endif
                    }
                    catch (Exception) {}
                }
            }

            JobFinished();
        }