public void HyperOmegaUInclNoPhase()
    {
        const float mass       = 1000f;
        GameObject  star       = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        GameObject  planet     = TestSetupUtils.CreatePlanetInHyper(star, 1f);
        OrbitHyper  orbitHyper = planet.GetComponent <OrbitHyper>();

        orbitHyper.ecc         = 1.4f;
        orbitHyper.perihelion  = 20f;
        orbitHyper.r_initial   = 20f;
        orbitHyper.inclination = 35f;

        // Try some values of om
        float[] omegaValues = { 30f, 45f, 60f, 90f, 135f, 180f, 210f, 275f, 355f };
        foreach (float omega in omegaValues)
        {
            orbitHyper.omega_uc = omega;
            TestSetupUtils.SetupGravityEngine(star, planet);

            orbitHyper.Log(System.Reflection.MethodBase.GetCurrentMethod().Name);
            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("omega = " + omega + " od.omega_uc=" + od.omega_uc);
            // Need a bit of leeway at 0 with error
            Assert.IsTrue(FloatEqualMod360(omega, od.omega_uc, 0.05));
        }
    }
    public void HyperInclination()
    {
        const float mass       = 1000f;
        GameObject  star       = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        GameObject  planet     = TestSetupUtils.CreatePlanetInHyper(star, 1f);
        OrbitHyper  orbitHyper = planet.GetComponent <OrbitHyper>();

        orbitHyper.ecc       = 1.4f;
        orbitHyper.r_initial = 20f;

        // Try some values of om
        float[] inclValues = { 30f, 45f, 60f, 90f, 135f, 180f, 0f };
        foreach (float incl in inclValues)
        {
            orbitHyper.inclination = incl;
            TestSetupUtils.SetupGravityEngine(star, planet);

            orbitHyper.Log(System.Reflection.MethodBase.GetCurrentMethod().Name);
            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("incl = " + incl + " od.incl=" + od.inclination);
            // Need a bit of leeway at 0 with error
            Assert.IsTrue(FloatEqual(incl, od.inclination, 0.02));
        }
    }
    public void HyperPhaseNoIncl()
    {
        const float mass       = 1000f;
        GameObject  star       = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        const float orbitPeri  = 15f;
        GameObject  planet     = TestSetupUtils.CreatePlanetInHyper(star, 1f);
        OrbitHyper  orbitHyper = planet.GetComponent <OrbitHyper>();

        orbitHyper.ecc        = 1.4f;
        orbitHyper.perihelion = orbitPeri;
        orbitHyper.r_initial  = orbitPeri;

        // Try some values of om
        float[] rinit_values = { orbitPeri, orbitPeri + 2f, orbitPeri + 5f, orbitPeri + 10f, orbitPeri + 20f };
        foreach (float rinit in rinit_values)
        {
            orbitHyper.r_initial = rinit;
            TestSetupUtils.SetupGravityEngine(star, planet);

            orbitHyper.Log(System.Reflection.MethodBase.GetCurrentMethod().Name);
            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("rinit = " + rinit + " od.r_initial=" + od.r_initial);
            // Need a bit of leeway at 0 with error
            TestRV(od, planet, star);
        }
    }
Exemple #4
0
    public void HyperOmegaLNoInclNoPhase()
    {
        const float mass       = 1000f;
        GameObject  star       = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        const float orbitPeri  = 15f;
        GameObject  planet     = TestSetupUtils.CreatePlanetInHyper(star, 1f);
        OrbitHyper  orbitHyper = planet.GetComponent <OrbitHyper>();

        orbitHyper.ecc        = 1.4f;
        orbitHyper.perihelion = orbitPeri;
        orbitHyper.r_initial  = orbitPeri;

        // Try some values of om
        float[] omegaValues = { 30f, 45f, 60f, 90f, 135f, 180f, 0f };
        foreach (float omega in omegaValues)
        {
            orbitHyper.omega_lc = omega;
            orbitHyper.Init();
            orbitHyper.InitNBody(1f, 1f);
            orbitHyper.Log(System.Reflection.MethodBase.GetCurrentMethod().Name);
            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("omega = " + omega + " od.omega_l=" + od.omega_lc);
            // Need a bit of leeway at 0 with error
            Assert.IsTrue(FloatEqual(omega, od.omega_lc, 0.05));
            TestRV(od, planet, star);
        }
    }
Exemple #5
0
    public void HyperInclOmega()
    {
        const float mass       = 1000f;
        GameObject  star       = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        GameObject  planet     = TestSetupUtils.CreatePlanetInHyper(star, 1f);
        OrbitHyper  orbitHyper = planet.GetComponent <OrbitHyper>();

        orbitHyper.r_initial = 20f;
        orbitHyper.ecc       = 2.5f;

        // Try some values of phase
        float[] inclinationValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f };
        float[] omegaUValues      = { 0f, 30f, 45f, 60f, 90f, 135f, 180f, 210f, 320f };
        foreach (float incl in inclinationValues)
        {
            foreach (float omegau in omegaUValues)
            {
                orbitHyper.inclination = incl;
                orbitHyper.omega_uc    = omegau;
                orbitHyper.Init();
                orbitHyper.InitNBody(1f, 1f);
                orbitHyper.Log("Initial circle:");
                OrbitData od = new OrbitData();
                od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
                Debug.Log("incl = " + incl + " od.incl=" + od.inclination);
                Debug.Log("omegaU = " + omegau + " od.omegau=" + od.omega_uc);
                TestRV(od, planet, star);
            }
        }
    }
Exemple #6
0
    public void HyperBasic()
    {
        const float mass       = 1000f;
        GameObject  star       = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        GameObject  planet     = TestSetupUtils.CreatePlanetInHyper(star, 1f);
        OrbitHyper  orbitHyper = planet.GetComponent <OrbitHyper>();

        // Try some values of om
        float[] eccValues = { 1.1f, 1.3f, 2f, 2.2f, 3f, 10f };
        foreach (float ecc in eccValues)
        {
            orbitHyper.ecc = ecc;
            orbitHyper.Init();
            orbitHyper.InitNBody(1f, 1f);
            orbitHyper.Log(System.Reflection.MethodBase.GetCurrentMethod().Name);
            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("ecc = " + ecc + " od.ecc=" + od.ecc);
            // Need a bit of leeway at 0 with error
            Assert.IsTrue(FloatEqual(ecc, od.ecc, 0.02));
        }
    }
    public void HyperInclOmega()
    {
        const float mass       = 1000f;
        GameObject  star       = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        GameObject  planet     = TestSetupUtils.CreatePlanetInHyper(star, 1f);
        OrbitHyper  orbitHyper = planet.GetComponent <OrbitHyper>();

        orbitHyper.r_initial = 20f;
        orbitHyper.ecc       = 2.5f;

        // Try some values of phase (incl=0 covered by another test)
        float[] inclinationValues = { 30f, 45f, 60f, 90f, 135f, 180f };
        float[] omegaUValues      = { 0f, 30f, 45f, 60f, 90f, 135f, 180f, 210f, 320f };
        foreach (float incl in inclinationValues)
        {
            foreach (float omegau in omegaUValues)
            {
                orbitHyper.inclination = incl;
                orbitHyper.omega_uc    = omegau;
                TestSetupUtils.SetupGravityEngine(star, planet);
                Debug.LogFormat("Test for i={0} omegaU={1}", incl, omegau);
                orbitHyper.Log("Initial circle:");
                OrbitData od = new OrbitData();
                od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
                Debug.Log("OrbitData: " + od.LogString());
                TestRV(od, planet, star);
                Debug.Log("incl = " + incl + " od.incl=" + od.inclination);
                Debug.Log("omegaU = " + omegau + " od.omegau=" + od.omega_uc + " od.omega_lc=" + od.omega_lc);
                if (incl != 180f)
                {
                    // 180 comes back as omegaL = omegaU = 180, but TestRV is ok
                    Assert.IsTrue(FloatEqual(incl, od.inclination, 0.02));
                    Assert.IsTrue(FloatEqualMod360(omegau, od.omega_uc, 0.02));
                }
            }
        }
    }