Esempio n. 1
0
    /// <summary>
    /// Set the integrator required for the chosen algorithm
    /// </summary>
    /// <param name="algorithm"></param>
    public void SetAlgorithmAndForce(GravityEngine.Algorithm algorithm, IForceDelegate forceDelegate)
    {
        this.forceDelegate = forceDelegate;
        // cast may be null if no force selection
        if (forceDelegate is SelectiveForceBase)
        {
            selectiveForce = (SelectiveForceBase)forceDelegate;
        }
        switch (algorithm)
        {
        case GravityEngine.Algorithm.LEAPFROG:
            integrator = new LeapFrogIntegrator(forceDelegate);
            break;

        //case GravityEngine.Algorithm.LEAPFROG_JOB:
        //    integrator = new LeapFrogJob(forceDelegate);
        //    break;
        case GravityEngine.Algorithm.HERMITE8:
            integrator = new HermiteIntegrator(forceDelegate);
            break;

        case GravityEngine.Algorithm.AZTRIPLE:
            integrator = new AZTripleIntegrator();
            break;

        default:
            Debug.LogError("Unknown algortithm");
            break;
        }
    }
Esempio n. 2
0
 public bool GetDataForSolutionName(string name, ref double[,] x, ref double[,] v,
                                    ref GravityEngine.Algorithm algorithm, ref float scale)
 {
     // E=0.8 is unstable after several iterations with Hermite and AZT
     scale = 1.0f;
     if (name == "Linear")
     {
         EulerLinear(ref x, ref v);
         // AZTRIPLE becomes unstable after several iterations.
     }
     else
     {
         string numStr       = name.Replace("E=", "");
         double eccentricity = 0;
         if (!Double.TryParse(numStr, out eccentricity))
         {
             Debug.LogError("Solution string " + numStr + " not of the form E=<0..1>");
             return(false);
         }
         LagrangeTriple(eccentricity, ref x, ref v);
         return(true);
     }
     algorithm = GravityEngine.Algorithm.HERMITE8;
     return(false);
 }
Esempio n. 3
0
    private void SetBodies(NBody[] nbodies)
    {
        double[,] x = new double[3, 3];
        double[,] v = new double[3, 3];
        GravityEngine.Algorithm algorithm = GravityEngine.Algorithm.AZTRIPLE;
        // Scale is a suggested visual scale based on how solution evolves.
        // Currently not used.
        float scale = 1.0f;             // visual scale to display solution

        if (!SolutionServer.Instance().GetData(solutionSet, solutionName, ref x, ref v, ref algorithm, ref scale))
        {
            Debug.LogError("Could not find set " + solutionSet + " soln=" + solutionName);
            return;
        }
        for (int i = 0; i < 3; i++)
        {
            nbodies[i].vel = new Vector3((float)v[i, 0], (float)v[i, 1], (float)v[i, 2]);
            // Awkward: Inflate positions by the NBE scale factor so that when NBE adds them (and removes the scale
            // factor) it comes out as a wash. This is because the literature uses [-1..1] and this awkward approach
            // is easier than scaling the velocities and masses.
            Vector3 position = new Vector3((float)x[i, 0], (float)x[i, 1], (float)x[i, 2]) * gravityEngine.physToWorldFactor;
            nbodies[i].initialPos         = position;
            nbodies[i].transform.position = position;
        }
        // solution server provides a per-solution algorithm
        GravityEngine.instance.algorithm = algorithm;
    }
Esempio n. 4
0
    public bool GetDataForSolutionName(string name, ref double[,] x, ref double[,] v,
                                       ref GravityEngine.Algorithm algorithm, ref float scale)
    {
        Solution solution = null;

        if (!solutionByName.TryGetValue(name, out solution))
        {
            Debug.LogError("Solution name " + name + " not found.");
            return(false);
        }
        scale = solution.scale;
        GetData(solution, ref x, ref v, ref algorithm);
        return(true);
    }
Esempio n. 5
0
    // Direct retrieval of a specific solution given a setname and solution name

    public bool GetData(string setName, string name, ref double[,] x, ref double[,] v,
                        ref GravityEngine.Algorithm algorithm, ref float scale)
    {
        // check everything (will support search someday?)
        ISolutionSet solutionSet = null;

        if (!solutionSets.TryGetValue(setName, out solutionSet))
        {
            return(false);
        }
        if (solutionSet != null)
        {
            // Debug.Log ("Load set=" + setName + " soln=" + name);
            return(solutionSet.GetDataForSolutionName(name, ref x, ref v, ref algorithm, ref scale));
        }
        Debug.LogError("Did not find solution=" + name);
        return(false);
    }
Esempio n. 6
0
    private void GetData(Solution s, ref double[,] x, ref double[,] v, ref GravityEngine.Algorithm algorithm)
    {
        algorithm = GravityEngine.Algorithm.AZTRIPLE;
        // using conservation CM velocity/position assign all values
        x[0, 0] = 1;
        x[0, 1] = 0;
        x[0, 2] = 0;
        x[1, 0] = -x[0, 0];
        x[1, 1] = 0;
        x[1, 2] = 0;
        x[2, 0] = 0;
        x[2, 1] = 0;
        x[2, 2] = 0;

        v[0, 0] = s.x1dot;
        v[0, 1] = s.y1dot;
        v[0, 2] = 0;
        v[1, 0] = v[0, 0];
        v[1, 1] = v[0, 1];
        v[1, 2] = 0;
        v[2, 0] = -2 * v[0, 0];
        v[2, 1] = -2 * v[0, 1];
        v[2, 2] = 0;
    }
Esempio n. 7
0
    public override void OnInspectorGUI()
    {
        GUI.changed = false;
        GravityEngine gravityEngine = (GravityEngine)target;
        float         massScale     = gravityEngine.massScale;
        float         timeScale     = gravityEngine.timeScale;
        float         lengthScale   = gravityEngine.lengthScale;

        float physToWorldFactor = gravityEngine.physToWorldFactor;

        bool optimizeMassless = gravityEngine.optimizeMassless;
        bool detectNbodies    = gravityEngine.detectNbodies;
        bool evolveAtStart    = gravityEngine.evolveAtStart;
        bool scaling          = gravityEngine.editorShowScale;
        bool showAdvanced     = gravityEngine.editorShowAdvanced;
        bool showTrajectory   = gravityEngine.editorShowTrajectory;
        bool cmFoldout        = gravityEngine.editorCMfoldout;
        bool mapToScene       = gravityEngine.mapToScene;

        bool       trajectoryPrediction = gravityEngine.trajectoryPrediction;
        float      trajectoryTime       = gravityEngine.trajectoryTime;
        GameObject trajCanvas           = gravityEngine.trajectoryCanvas;
        GameObject markerParent         = gravityEngine.markerParent;
        float      computeFactor        = gravityEngine.trajectoryComputeFactor;

        int stepsPerFrame         = gravityEngine.stepsPerFrame;
        int particleStepsPerFrame = gravityEngine.particleStepsPerFrame;

        GravityEngine.Algorithm algorithm = GravityEngine.Algorithm.LEAPFROG;
        ForceChooser.Forces     force     = ForceChooser.Forces.Gravity;
        GravityScaler.Units     units     = GravityScaler.Units.DIMENSIONLESS;

        EditorGUIUtility.labelWidth = 200;

        mapToScene = EditorGUILayout.Toggle(new GUIContent("Use Transform to Reposition", mapTip), mapToScene);

        EditorGUIUtility.labelWidth = 150;

        // SCALING
        scaling = EditorGUILayout.Foldout(scaling, "Scaling");
        if (scaling)
        {
            units =
                (GravityScaler.Units)EditorGUILayout.EnumPopup(new GUIContent("Units", unitsTip), gravityEngine.units);
            EditorGUILayout.LabelField("Scaling values change when <ENTER> ispressed.");

            switch (units)
            {
            case GravityScaler.Units.DIMENSIONLESS:
                // only have mass scale in DL case
                EditorGUILayout.LabelField("Use mass scale to control scene speed.");
                EditorGUILayout.LabelField("(More massive = faster)");
                massScale = EditorGUILayout.DelayedFloatField(new GUIContent("Mass Scale", mTip), gravityEngine.massScale);
                break;

            case GravityScaler.Units.SI:
                // no mass scale is controlled by time exclusivly
                EditorGUILayout.LabelField("m/kg/sec.");
                // meters per Unity unit in the case of meters
                lengthScale = EditorGUILayout.DelayedFloatField(new GUIContent("Unity unit per m", timeTip), gravityEngine.lengthScale);
                timeScale   = EditorGUILayout.DelayedFloatField(new GUIContent("Game sec. per sec.", timeTip), gravityEngine.timeScale);
                break;

            case GravityScaler.Units.ORBITAL:
                EditorGUILayout.LabelField("km/1E24 kg/hr");
                // Express in km per Unity unit km/U
                lengthScale = EditorGUILayout.DelayedFloatField(new GUIContent("Unity unit per km", timeTip), gravityEngine.lengthScale);
                timeScale   = EditorGUILayout.DelayedFloatField(new GUIContent("Game sec. per hour", timeTip), gravityEngine.timeScale);
                break;

            case GravityScaler.Units.SOLAR:
                EditorGUILayout.LabelField("AU/1E24 kg/year");
                lengthScale = EditorGUILayout.DelayedFloatField(new GUIContent("Unity unit per AU", timeTip), gravityEngine.lengthScale);
                timeScale   = EditorGUILayout.DelayedFloatField(new GUIContent("Game Sec per year", timeTip), gravityEngine.timeScale);
                break;
            }
        }

        // TRAJECTORY PREDICTION
        showTrajectory = EditorGUILayout.Foldout(showTrajectory, "Trajectory Prediction");
        if (showTrajectory)
        {
            trajectoryPrediction = EditorGUILayout.Toggle(new GUIContent("Trajectory Prediction", trajTip), trajectoryPrediction);
            trajectoryTime       = EditorGUILayout.FloatField(new GUIContent("Trajectory Time", trajTimeTip), trajectoryTime);
            computeFactor        = EditorGUILayout.FloatField(new GUIContent("Re-computes per frame)", trajResetTip), computeFactor);
            trajCanvas           = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Canvas for Text (optional)", trajCanvasTip),
                                                                           trajCanvas, typeof(GameObject), true);
            markerParent = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Time Marker Parent (optional)", markerTip),
                                                                   markerParent, typeof(GameObject), true);
        }

        // ADVANCED
        showAdvanced = EditorGUILayout.Foldout(showAdvanced, "Advanced");
        if (showAdvanced)
        {
            algorithm =
                (GravityEngine.Algorithm)EditorGUILayout.EnumPopup(new GUIContent("Algorithm", algoTip), gravityEngine.algorithm);

            // Force selection is tangled with choice of integrator and scale - so needs to be here
            force =
                (ForceChooser.Forces)EditorGUILayout.EnumPopup(new GUIContent("Force", forceTip), gravityEngine.force);
            if (force == ForceChooser.Forces.Custom)
            {
                IForceDelegate force_delegate = gravityEngine.GetComponent <IForceDelegate>();
                if (force_delegate == null)
                {
                    EditorGUILayout.LabelField("  Attach a Force Delegate to this object.", EditorStyles.boldLabel);
                }
                else
                {
                    EditorGUILayout.LabelField("  Force delegate: " + force_delegate.GetType());
                }
            }
            if (force != ForceChooser.Forces.Gravity)
            {
                EditorGUILayout.LabelField("    Note: Orbit predictors assume Newtonian gravity");
                EditorGUILayout.LabelField("    They are not accurate for other forces.");
            }

            optimizeMassless = EditorGUILayout.Toggle(new GUIContent("Optimize Massless Bodies", mlessTip),
                                                      gravityEngine.optimizeMassless);
            detectNbodies     = EditorGUILayout.Toggle(new GUIContent("Automatically Add NBody objects", autoAddTip), gravityEngine.detectNbodies);
            evolveAtStart     = EditorGUILayout.Toggle(new GUIContent("Evolve at Start", autoStartTip), gravityEngine.evolveAtStart);
            physToWorldFactor = EditorGUILayout.FloatField(new GUIContent("Physics to World Scale", phyWTip), gravityEngine.physToWorldFactor);

            EditorGUILayout.LabelField("Steps per frame:");
            stepsPerFrame         = EditorGUILayout.IntField(new GUIContent("  Massive Bodies", stepTip), stepsPerFrame);
            particleStepsPerFrame = EditorGUILayout.IntField(new GUIContent("  Particles", pstepTip), particleStepsPerFrame);
        }
        // Switch bodies list on/off based on option
        if (!gravityEngine.detectNbodies)
        {
            // use native Inspector look & feel for bodies object
            EditorGUILayout.LabelField("Control Nbody in following gameObjects (and children)", EditorStyles.boldLabel);
            SerializedProperty bodiesProp = serializedObject.FindProperty("bodies");
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(bodiesProp, true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
        else
        {
            EditorGUILayout.LabelField("NBody objects will be detected automatically", EditorStyles.boldLabel);
        }
        // Show the CM and the velocity of the CM
        cmFoldout = EditorGUILayout.Foldout(cmFoldout, "Center of Mass Info");
        if (cmFoldout)
        {
            EditorGUILayout.LabelField("Center of Mass:" + gravityEngine.GetWorldCenterOfMass());
            EditorGUILayout.LabelField("CM Velocity:" + gravityEngine.GetWorldCenterOfMassVelocity());
        }


        // Checking the Event type lets us update after Undo and Redo commands.
        // A redo updates _lengthScale but does not run the setter
        if (Event.current.type == EventType.ExecuteCommand &&
            Event.current.commandName == "UndoRedoPerformed")
        {
            // explicitly re-set so setter code will run.
            gravityEngine.lengthScale = lengthScale;
        }

        if (GUI.changed)
        {
            Undo.RecordObject(gravityEngine, "GE Change");
            gravityEngine.mapToScene = mapToScene;

            gravityEngine.timeScale = timeScale;
            gravityEngine.massScale = massScale;
            // This runs a setter in GE that will do a rescale of the scene if necessary
            gravityEngine.lengthScale       = lengthScale;
            gravityEngine.units             = units;
            gravityEngine.physToWorldFactor = physToWorldFactor;
            gravityEngine.optimizeMassless  = optimizeMassless;
            gravityEngine.detectNbodies     = detectNbodies;

            gravityEngine.editorShowTrajectory    = showTrajectory;
            gravityEngine.trajectoryPrediction    = trajectoryPrediction;
            gravityEngine.trajectoryTime          = trajectoryTime;
            gravityEngine.trajectoryCanvas        = trajCanvas;
            gravityEngine.markerParent            = markerParent;
            gravityEngine.trajectoryComputeFactor = computeFactor;

            gravityEngine.algorithm             = algorithm;
            gravityEngine.force                 = force;
            gravityEngine.evolveAtStart         = evolveAtStart;
            gravityEngine.editorShowScale       = scaling;
            gravityEngine.editorShowAdvanced    = showAdvanced;
            gravityEngine.editorCMfoldout       = cmFoldout;
            gravityEngine.stepsPerFrame         = stepsPerFrame;
            gravityEngine.particleStepsPerFrame = particleStepsPerFrame;
            EditorUtility.SetDirty(gravityEngine);
        }
    }
Esempio n. 8
0
    public bool GetDataForSolutionName(string name, ref double[,] x, ref double[,] v,
                                       ref GravityEngine.Algorithm algorithm, ref float scale)
    {
        // data from http://suki.ipb.ac.rs/3body/
        // original work: R. Broucke, On relative periodic solutions of the planar general three-body problem,
        // Celest. Mech. 12, 439 (1975).
        scale     = 0.8f;
        algorithm = GravityEngine.Algorithm.AZTRIPLE;
        string numStr = name.Replace("A", "");

        int num = 0;

        if (!int.TryParse(numStr, out num))
        {
            Debug.LogError("Solution string " + numStr + " not of the form A<1-16>");
            return(false);
        }
        ;
        num -= 1;         // 0 based
        if (num < 0 || num > 15)
        {
            Debug.LogError("Solution number " + numStr + " out of range");
            return(false);
        }
        switch (num)
        {
        case 0:
            // var text = 'NAME: Broucke A 1 %
            x[0, 0] = -0.9892620043;
            x[1, 0] = 2.2096177241;
            x[2, 0] = -1.2203557197;
            v[0, 1] = 1.9169244185;
            v[1, 1] = 0.1910268738;
            v[2, 1] = -2.1079512924;
            break;

        case 1:
            // var text = 'NAME: Broucke A 2 %
            x[0, 0] = 0.3361300950;
            x[1, 0] = 0.7699893804;
            x[2, 0] = -1.1061194753;
            v[0, 1] = 1.5324315370;
            v[1, 1] = -0.6287350978;
            v[2, 1] = -0.9036964391;
            break;

        case 2:
            // var text = 'NAME: Broucke A 3 %
            x[0, 0] = 0.3149337497;
            x[1, 0] = 0.8123820710;
            x[2, 0] = -1.1273158206;
            v[0, 1] = 1.4601869417;
            v[1, 1] = -0.5628292375;
            v[2, 1] = -0.8973577042;
            break;

        case 3:
            // var text = 'NAME: Broucke A 4 %
            x[0, 0] = 0.2843198916;
            x[1, 0] = 0.8736097872;
            x[2, 0] = -1.1579296788;
            v[0, 1] = 1.3774179570;
            v[1, 1] = -0.4884226932;
            v[2, 1] = -0.8889952638;
            break;

        case 4:
            // var text = 'NAME: Broucke A 5 %
            x[0, 0] = 0.2355245585;
            x[1, 0] = 0.9712004534;
            x[2, 0] = -1.2067250118;
            v[0, 1] = 1.2795329643;
            v[1, 1] = -0.4021329019;
            v[2, 1] = -0.8774000623;
            break;

        case 5:
            // var text = 'NAME: Broucke A 6 %
            x[0, 0] = 0.1432778606;
            x[1, 0] = 1.1556938491;
            x[2, 0] = -1.2989717097;
            v[0, 1] = 1.1577475241;
            v[1, 1] = -0.2974667752;
            v[2, 1] = -0.8602807489;
            break;

        case 6:
            // var text = 'NAME: Broucke A 7 %
            x[0, 0] = -0.1095519101;
            x[1, 0] = 1.6613533905;
            x[2, 0] = -1.5518014804;
            v[0, 1] = 0.9913358338;
            v[1, 1] = -0.1569959746;
            v[2, 1] = -0.8343398592;
            scale   = 0.7f;
            break;

        case 7:
            // var text = 'NAME: Broucke A 8 %
            x[0, 0] = 0.1979259967;
            x[1, 0] = 1.0463975768;
            x[2, 0] = -1.2443235736;
            v[0, 1] = 1.2224733132;
            v[1, 1] = -0.3527351133;
            v[2, 1] = -0.8697381999;
            scale   = 0.7f;
            break;

        case 8:
            // var text = 'NAME: Broucke A 9 %
            x[0, 0] = 0.0557080334;
            x[1, 0] = 1.3308335036;
            x[2, 0] = -1.3865415370;
            v[0, 1] = 1.0824099428;
            v[1, 1] = -0.2339059386;
            v[2, 1] = -0.8485040042;
            scale   = 0.7f;
            break;

        case 9:
            // var text = 'NAME: Broucke A 10 %
            x[0, 0] = -0.5426216182;
            x[1, 0] = 2.5274928067;
            x[2, 0] = -1.9848711885;
            v[0, 1] = 0.8750200467;
            v[1, 1] = -0.0526955841;
            v[2, 1] = -0.8223244626;
            scale   = 0.5f;
            break;

        case 10:
            // var text = 'NAME: Broucke A 11 %
            x[0, 0] = 0.0132604844;
            x[1, 0] = 1.4157286016;
            x[2, 0] = -1.4289890859;
            v[0, 1] = 1.0541519210;
            v[1, 1] = -0.2101466639;
            v[2, 1] = -0.8440052572;
            scale   = 0.7f;
            break;

        case 11:
            // var text = 'NAME: Broucke A 12 %
            x[0, 0] = -0.3370767020;
            x[1, 0] = 2.1164029743;
            x[2, 0] = -1.7793262723;
            v[0, 1] = 0.9174260238;
            v[1, 1] = -0.0922665014;
            v[2, 1] = -0.8251595224;
            scale   = 0.5f;
            break;

        case 12:
            // var text = 'NAME: Broucke A 13 %
            x[0, 0] = -0.8965015243;
            x[1, 0] = 3.2352526189;
            x[2, 0] = -2.3387510946;
            v[0, 1] = 0.8285556923;
            v[1, 1] = -0.0056478094;
            v[2, 1] = -0.8229078829;
            scale   = 0.3f;
            break;

        case 13:
            // var text = 'NAME: Broucke A 14 %
            x[0, 0] = -0.2637815221;
            x[1, 0] = 1.9698126146;
            x[2, 0] = -1.7060310924;
            v[0, 1] = 0.9371630895;
            v[1, 1] = -0.1099503287;
            v[2, 1] = -0.8272127608;
            scale   = 0.5f;
            break;

        case 14:
            // var text = 'NAME: Broucke A 15 %
            x[0, 0] = -1.1889693067;
            x[1, 0] = 3.8201881837;
            x[2, 0] = -2.6312188770;
            v[0, 1] = 0.8042120498;
            v[1, 1] = 0.0212794833;
            v[2, 1] = -0.8254915331;
            scale   = 0.4f;
            break;

        case 15:
            // var text = 'NAME: Broucke A 16 %
            x[0, 0] = -0.7283341038;
            x[1, 0] = 2.8989177778;
            x[2, 0] = -2.1705836741;
            v[0, 1] = 0.8475982451;
            v[1, 1] = -0.0255162097;
            v[2, 1] = -0.8220820354;
            scale   = 0.3f;
            break;

        default:
            Debug.LogError("Unknown solution " + name);
            break;
        }
        return(true);
    }
Esempio n. 9
0
    public bool GetDataForSolutionName(string name, ref double[,] x, ref double[,] v,
                                       ref GravityEngine.Algorithm algorithm, ref float scale)
    {
        // data from http://suki.ipb.ac.rs/3body/
        // original work: R. Broucke, On relative periodic solutions of the planar general three-body problem,
        // Celest. Mech. 12, 439 (1975).
        scale     = 1.0f;
        algorithm = GravityEngine.Algorithm.AZTRIPLE;
        string numStr = name.Replace("R", "");
        int    num    = 0;

        if (!int.TryParse(numStr, out num))
        {
            Debug.LogError("Solution string " + numStr + " not of the form R<1-13>");
            return(false);
        }
        ;
        num -= 1;         // 0 based
        if (num < 0 || num > 12)
        {
            Debug.LogError("Solution number " + numStr + " out of range");
            return(false);
        }
        switch (num)
        {
        case 0:
            // var text = 'NAME: Broucke R 1 %
            x[0, 0] = 0.8083106230;
            x[1, 0] = -0.4954148566;
            x[2, 0] = -0.3128957664;
            v[0, 1] = 0.9901979166;
            v[1, 1] = -2.7171431768;
            v[2, 1] = 1.7269452602;
            break;

        case 1:
            // var text = 'NAME: Broucke R 2 %
            x[0, 0] = 0.9060893715;
            x[1, 0] = -0.6909723536;
            x[2, 0] = -0.2151170179;
            v[0, 1] = 0.9658548899;
            v[1, 1] = -1.6223214842;
            v[2, 1] = 0.6564665942;
            break;

        case 2:
            // var text = 'NAME: Broucke R 3 %
            x[0, 0] = 0.8920281421;
            x[1, 0] = -0.6628498947;
            x[2, 0] = -0.2291782474;
            v[0, 1] = 0.9957939373;
            v[1, 1] = -1.6191613336;
            v[2, 1] = 0.6233673964;
            break;

        case 3:
            // var text = 'NAME: Broucke R 4 %
            x[0, 0] = 0.8733047091;
            x[1, 0] = -0.6254030288;
            x[2, 0] = -0.2479016803;
            v[0, 1] = 1.0107764436;
            v[1, 1] = -1.6833533458;
            v[2, 1] = 0.6725769022;
            break;

        case 4:
            // var text = 'NAME: Broucke R 5 %
            x[0, 0] = 0.8584630769;
            x[1, 0] = -0.5957197644;
            x[2, 0] = -0.2627433125;
            v[0, 1] = 1.0204773541;
            v[1, 1] = -1.7535566440;
            v[2, 1] = 0.7330792899;
            break;

        case 5:
            // var text = 'NAME: Broucke R 6 %
            x[0, 0] = 0.8469642946;
            x[1, 0] = -0.5727221998;
            x[2, 0] = -0.2742420948;
            v[0, 1] = 1.0275065708;
            v[1, 1] = -1.8209307202;
            v[2, 1] = 0.7934241494;
            break;

        case 6:
            // var text = 'NAME: Broucke R 7 %
            x[0, 0] = 0.8378824453;
            x[1, 0] = -0.5545585011;
            x[2, 0] = -0.2833239442;
            v[0, 1] = 1.0329242005;
            v[1, 1] = -1.8840083393;
            v[2, 1] = 0.8510841387;
            break;

        case 7:
            // var text = 'NAME: Broucke R 8 %
            x[0, 0]   = 0.8871256555;
            x[1, 0]   = -0.6530449215;
            x[2, 0]   = -0.2340807340;
            v[0, 1]   = 0.9374933545;
            v[1, 1]   = -1.7866975426;
            v[2, 1]   = 0.8492041880;
            algorithm = GravityEngine.Algorithm.HERMITE8;
            break;

        case 8:
            // var text = 'NAME: Broucke R 9 %
            x[0, 0] = 0.9015586070;
            x[1, 0] = -0.6819108246;
            x[2, 0] = -0.2196477824;
            v[0, 1] = 0.9840575737;
            v[1, 1] = -1.6015183264;
            v[2, 1] = 0.6174607527;
            break;

        case 9:
            // var text = 'NAME: Broucke R 10 %
            x[0, 0] = 0.8822391241;
            x[1, 0] = -0.6432718586;
            x[2, 0] = -0.2389672654;
            v[0, 1] = 1.0042424155;
            v[1, 1] = -1.6491842814;
            v[2, 1] = 0.6449418659;
            break;

        case 10:
            // var text = 'NAME: Broucke R 11 %
            x[0, 0] = 0.8983487470;
            x[1, 0] = -0.6754911045;
            x[2, 0] = -0.2228576425;
            v[0, 1] = 0.9475564971;
            v[1, 1] = -1.7005860354;
            v[2, 1] = 0.7530295383;
            break;

        case 11:
            // var text = 'NAME: Broucke R 12 %
            x[0, 0] = 0.9040866398;
            x[1, 0] = -0.6869668901;
            x[2, 0] = -0.2171197497;
            v[0, 1] = 0.9789534005;
            v[1, 1] = -1.6017790202;
            v[2, 1] = 0.6228256196;
            break;

        case 12:
            // var text = 'NAME: Broucke R 13 %
            x[0, 0] = 0.9017748598;
            x[1, 0] = -0.6823433302;
            x[2, 0] = -0.2194315296;
            v[0, 1] = 0.9526089117;
            v[1, 1] = -1.6721104565;
            v[2, 1] = 0.7195015448;
            break;

        default:
            Debug.LogError("Unknown solution " + name + " case=" + num);
            break;
        }
        return(true);
    }
Esempio n. 10
0
    // Update is called once per frame
    public bool GetDataForSolutionName(string name, ref double[,] x, ref double[,] v,
                                       ref GravityEngine.Algorithm algorithm, ref float scale)
    {
        // data from http://suki.ipb.ac.rs/3body/
        // original work: R. Broucke, On relative periodic solutions of the planar general three-body problem,
        // Celest. Mech. 12, 439 (1975).
        scale     = 0.8f;
        algorithm = GravityEngine.Algorithm.AZTRIPLE;
        string numStr = name.Replace("H", "");
        int    num    = 0;

        if (!int.TryParse(numStr, out num))
        {
            Debug.LogError("Solution string " + numStr + " not of the form A<1-16>");
            return(false);
        }
        ;
        num -= 1;         // 0 based
        if (num < 0 || num > 15)
        {
            Debug.LogError("Solution number " + numStr + " out of range");
            return(false);
        }
        switch (num)
        {
        case 0:
            // var text = 'NAME: Henon 2 %
            x[0, 0] = -1.0207041786;
            x[1, 0] = 2.0532718983;
            x[2, 0] = -1.0325677197;
            v[0, 1] = 9.1265693140;
            v[1, 1] = 0.0660238922;
            v[2, 1] = -9.1925932061;
            break;

        case 1:
            // var text = 'NAME: Henon 3 %
            x[0, 0] = -0.9738300580;
            x[1, 0] = 1.9988948637;
            x[2, 0] = -1.0250648057;
            v[0, 1] = 4.3072892019;
            v[1, 1] = 0.1333821680;
            v[2, 1] = -4.4406713699;
            break;

        case 2:
            // var text = 'NAME: Henon 4 %
            x[0, 0] = -0.9418961718;
            x[1, 0] = 1.9620504351;
            x[2, 0] = -1.0201542632;
            v[0, 1] = 3.4407426089;
            v[1, 1] = 0.1608086204;
            v[2, 1] = -3.6015512293;
            break;

        case 3:
            // var text = 'NAME: Henon 5 %
            x[0, 0] = -0.9353825545;
            x[1, 0] = 1.9545571553;
            x[2, 0] = -1.0191746008;
            v[0, 1] = 3.3166932522;
            v[1, 1] = 0.1654488998;
            v[2, 1] = -3.4821421520;
            break;

        case 4:
            // var text = 'NAME: Henon 6 %
            x[0, 0] = -0.9213822197;
            x[1, 0] = 1.9384775293;
            x[2, 0] = -1.0170953096;
            v[0, 1] = 3.0865413013;
            v[1, 1] = 0.1745212698;
            v[2, 1] = -3.2610625710;
            break;

        case 5:
            // var text = 'NAME: Henon 7 %
            x[0, 0] = -0.8961968933;
            x[1, 0] = 1.9096454316;
            x[2, 0] = -1.0134485383;
            v[0, 1] = 2.7626477723;
            v[1, 1] = 0.1880576473;
            v[2, 1] = -2.9507054196;
            break;

        case 6:
            // var text = 'NAME: Henon 8 %
            x[0, 0] = -0.8630680168;
            x[1, 0] = 1.8719091735;
            x[2, 0] = -1.0088411567;
            v[0, 1] = 2.4494921664;
            v[1, 1] = 0.2009780545;
            v[2, 1] = -2.6504702209;
            break;

        case 7:
            // var text = 'NAME: Henon 9 %
            x[0, 0] = -0.8406614871;
            x[1, 0] = 1.8465095288;
            x[2, 0] = -1.0058480417;
            v[0, 1] = 2.2849981945;
            v[1, 1] = 0.2067721191;
            v[2, 1] = -2.4917703136;
            break;

        case 8:
            // var text = 'NAME: Henon 10 %
            x[0, 0] = -0.8189887884;
            x[1, 0] = 1.8220335296;
            x[2, 0] = -1.0030447412;
            v[0, 1] = 2.1515812682;
            v[1, 1] = 0.2101820298;
            v[2, 1] = -2.3617632980;
            break;

        case 9:
            // var text = 'NAME: Henon 11 %
            x[0, 0] = -0.8124282691;
            x[1, 0] = 1.8146415679;
            x[2, 0] = -1.0022132988;
            v[0, 1] = 2.1152813609;
            v[1, 1] = 0.2107937022;
            v[2, 1] = -2.3260750631;
            break;

        case 10:
            // var text = 'NAME: Henon 12 %
            x[0, 0] = -0.8081346489;
            x[1, 0] = 1.8098115895;
            x[2, 0] = -1.0016769406;
            v[0, 1] = 2.0924392285;
            v[1, 1] = 0.2110889451;
            v[2, 1] = -2.3035281737;
            break;

        case 11:
            // var text = 'NAME: Henon 30 %
            x[0, 0] = -0.1539168309;
            x[1, 0] = 1.1825813762;
            x[2, 0] = -1.0286645453;
            v[0, 1] = 1.2071375933;
            v[1, 1] = -0.1445299063;
            v[2, 1] = -1.0626076870;
            break;

        case 12:
            // var text = 'NAME: Henon 31 %
            x[0, 0] = -0.1184831386;
            x[1, 0] = 1.1644627554;
            x[2, 0] = -1.0459796167;
            v[0, 1] = 1.2002882491;
            v[1, 1] = -0.1648687837;
            v[2, 1] = -1.0354194654;
            break;

        case 13:
            // var text = 'NAME: Henon 39 %
            x[0, 0] = 0.3492734869;
            x[1, 0] = 1.1741828108;
            x[2, 0] = -1.5234562977;
            v[0, 1] = 1.1785487598;
            v[1, 1] = -0.4017802411;
            v[2, 1] = -0.7767685187;
            break;

        case 14:
            // var text = 'NAME: Henon 41 %
            x[0, 0] = 0.8008933013;
            x[1, 0] = 1.4695233462;
            x[2, 0] = -2.2704166475;
            v[0, 1] = 1.1815913872;
            v[1, 1] = -0.5532095521;
            v[2, 1] = -0.6283818352;
            break;

        case 15:
            // var text = 'NAME: Henon 44 %
            x[0, 0] = 3.0372729887;
            x[1, 0] = 3.5696472554;
            x[2, 0] = -6.6069202441;
            v[0, 1] = 1.1526391069;
            v[1, 1] = -0.7857412148;
            v[2, 1] = -0.3668978921;
            break;
        }
        return(true);
    }