コード例 #1
0
    public void SliderChanged(bool value)
    {
        PatchedConicXfer conicXfer = (PatchedConicXfer)transfer;
        float            lambda    = lambdaSlider.value;

        lambdaValue.text = string.Format("{0:0.0}", lambdaSlider.value);
        transfer         = conicXfer.CreateTransferCopy(lambda);
        UpdateUI(transfer);
    }
コード例 #2
0
    /// <summary>
    /// Initiate a transfer of the spaceship to the moon. The name of the targets[] entry that is the moon
    /// is provided as a string argument.
    ///
    /// Typically called by the GEConsole.
    /// </summary>
    public string MoonTransfer(string moonName, float angle)
    {
        // Find xfer choices and present to user
        OrbitData shipOrbit = new OrbitData();

        shipOrbit.SetOrbit(spaceshipCtrl.GetNBody(), centralMass);
        OrbitData targetOrbit = new OrbitData();

        targetOrbit.SetOrbit(GetTargetByName(moonName), centralMass);
        OrbitTransfer xfer = new PatchedConicXfer(shipOrbit, targetOrbit, angle);

        spaceshipCtrl.SetTransfer(xfer);
        SetState(State.MANEUVER);
        // display the maneuver in the console (will only be one for patched conic)
        return(xfer.GetManeuvers()[0].LogString() + "\n");
    }
コード例 #3
0
    public string MoonPreview(string moonName, float lambda1, bool async)
    {
        // Step 1: Determine the patched conic xfer
        OrbitData shipOrbit = new OrbitData();
        NBody     shipNbody = spaceshipCtrl.GetNBody();

        shipOrbit.SetOrbit(shipNbody, centralMass);
        OrbitData moonOrbit = new OrbitData();
        NBody     moonNbody = GetTargetByName(moonName);

        moonOrbit.SetOrbit(moonNbody, centralMass);
        OrbitTransfer xfer = new PatchedConicXfer(shipOrbit, moonOrbit, lambda1);

        // Step 2: Make a copy of the universe state and evolve forward to find min distance to
        // moon.
        GravityEngine ge = GravityEngine.Instance();
        GravityState  gs = ge.GetGravityStateCopy();

        // there is only one maneuver to add
        gs.maneuverMgr.Add(xfer.GetManeuvers()[0]);
        // run a simulation and find the closest approach (Expensive!)
        LunarCourseCorrection lcc = new LunarCourseCorrection(shipNbody, moonNbody);

        // want to be within 10% of Earth-Moon distance, before start checking
        courseCorrectionData = new LunarCourseCorrection.CorrectionData();
        courseCorrectionData.gravityState     = gs;
        courseCorrectionData.approachDistance = 0.1f * moonOrbit.a;;
        courseCorrectionData.correction       = 0;
        courseCorrectionData.maxPhysTime      = time_to_moon_phys;
        // Direct (unthreaded) calculation
        if (async)
        {
            lcc.ClosestApproachAsync(courseCorrectionData, MoonPreviewCompleted);
            return("Calculation started...\n");
        }
        else
        {
            predictedDistance = lcc.ClosestApproach(courseCorrectionData);
            return(string.Format("Patched Conic with lambda={0} => approach={1}\n", lambda1, predictedDistance));
        }
    }
コード例 #4
0
    public PatchedConicXfer CreateTransferCopy(double lambda1Deg)
    {
        PatchedConicXfer newXfer = new PatchedConicXfer(this.fromOrbit, this.toOrbit, lambda1Deg);

        return(newXfer);
    }