public void OmegaUCircleInclination()
    {
        const float    mass        = 1000f;
        GameObject     star        = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        NBody          starNbody   = star.GetComponent <NBody>();
        const float    orbitRadius = 10f;
        GameObject     planet      = TestSetupUtils.CreatePlanetInOrbitUniversal(starNbody, 1f, orbitRadius);
        OrbitUniversal orbitU      = planet.GetComponent <OrbitUniversal>();

        orbitU.eccentricity = 0.0f;
        orbitU.inclination  = 5;
        orbitU.SetMajorAxisInspector(orbitRadius);
        // Try some values of om
        float[] omegaValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f, 210f, 320f };
        foreach (float omega in omegaValues)
        {
            orbitU.omega_uc = omega;
            TestSetupUtils.SetupGravityEngine(star, planet);

            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("Omega = " + omega + " od.omega_lc=" + od.omega_lc + " od:" + od.LogString());
            Assert.IsTrue(GEUnit.FloatEqual(omega, od.omega_uc, 0.1));
        }
    }
Exemplo n.º 2
0
    public void HyperOmegaLIncl()
    {
        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;
        orbitHyper.inclination = 40f;

        // Try some values of om
        float[] omegaValues = { 30f, 45f, 60f, 90f, 135f, 180f, 1f, 358f };
        foreach (float omega in omegaValues)
        {
            orbitHyper.omega_lc = 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(od.LogString());
            Debug.Log("omega = " + omega + " od.omega_l=" + od.omega_lc);
            // Need a bit of leeway at 0 with error
            Assert.IsTrue(FloatEqualMod360(omega, od.omega_lc, 0.02));
        }
    }
Exemplo n.º 3
0
    public void OmegaULEllipseInclined()
    {
        const float  mass         = 1000f;
        GameObject   star         = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        const float  orbitRadius  = 10f;
        GameObject   planet       = TestSetupUtils.CreatePlanetInOrbit(star, 1f, orbitRadius);
        OrbitEllipse orbitEllipse = planet.GetComponent <OrbitEllipse>();

        orbitEllipse.InitNBody(1f, 1f);

        orbitEllipse.inclination = 30f;
        orbitEllipse.ecc         = 0.2f;
        orbitEllipse.Init();
        orbitEllipse.ApplyScale(1f);
        orbitEllipse.InitNBody(1f, 1f);

        // Try some values of om
        float[] omegaUValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f, 210f, 310f };
        float[] omegaLValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f, 210f, 310f };
        foreach (float omegaU in omegaUValues)
        {
            foreach (float omegaL in omegaLValues)
            {
                orbitEllipse.omega_uc = omegaU;
                orbitEllipse.omega_lc = omegaL;
                TestSetupUtils.SetupGravityEngine(star, planet);

                orbitEllipse.Log("OmegaUL inclined:");
                OrbitData od = new OrbitData();
                od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
                Debug.Log("omegaU = " + omegaU + "omegaL = " + omegaL + " OD:=" + od.LogString());
                TestRV(od, planet, star, orbitRadius);
            }
        }
    }
Exemplo n.º 4
0
    public void CirclePhaseOmegaInclined()
    {
        const float  mass         = 1000f;
        GameObject   star         = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        const float  orbitRadius  = 10f;
        GameObject   planet       = TestSetupUtils.CreatePlanetInOrbit(star, 1f, orbitRadius);
        OrbitEllipse orbitEllipse = planet.GetComponent <OrbitEllipse>();

        orbitEllipse.inclination = 20f;

        // Try some values of phase
        // omegaU for a circle does not make sense, no axis to relate it to.
        float[] phaseValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f, 210f, 320f };
        foreach (float phase in phaseValues)
        {
            orbitEllipse.phase    = phase;
            orbitEllipse.omega_uc = 0;
            TestSetupUtils.SetupGravityEngine(star, planet);
            Debug.LogFormat("Test for phase={0} omegau={1}", phase, 0);
            orbitEllipse.Log("Initial circle:");
            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("OrbitData: " + od.LogString());
            Assert.IsTrue(FloatEqualMod360(phase, od.phase, 0.05));
            Assert.IsTrue(FloatEqualMod360(0, od.omega_uc, 0.05));
            TestRV(od, planet, star, orbitRadius);
        }
    }
Exemplo n.º 5
0
    public void PhaseNoInclinationEllipse()
    {
        const float  mass         = 1000f;
        GameObject   star         = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        const float  orbitRadius  = 20f;
        GameObject   planet       = TestSetupUtils.CreatePlanetInOrbit(star, 1f, orbitRadius);
        OrbitEllipse orbitEllipse = planet.GetComponent <OrbitEllipse>();

        orbitEllipse.ecc = 0.2f;

        // Try some values of om
        float[] phaseValues = { 30f, 45f, 60f, 90f, 135f, 180f, 225f, 270f, 325f, 0f };
        foreach (float phase in phaseValues)
        {
            orbitEllipse.phase = phase;
            TestSetupUtils.SetupGravityEngine(star, planet);

            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            orbitEllipse.Log("PhaseNoInclinationEllipse:");
            Debug.Log(od.LogString());
            // Need a bit of leeway at 0 with error
            Assert.IsTrue(FloatEqualMod360(phase, od.phase, 0.02));
            Assert.IsTrue(FloatEqualMod360(0f, od.omega_lc, 0.02));
            Assert.IsTrue(FloatEqualMod360(0f, od.omega_uc, 0.02));
            TestRV(od, planet, star, orbitRadius);
        }
    }
Exemplo n.º 6
0
    public void OmegaUNoInclination()
    {
        const float  mass         = 1000f;
        GameObject   star         = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        const float  orbitRadius  = 10f;
        GameObject   planet       = TestSetupUtils.CreatePlanetInOrbit(star, 1f, orbitRadius);
        OrbitEllipse orbitEllipse = planet.GetComponent <OrbitEllipse>();

        orbitEllipse.ecc = 0.1f;

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

            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("Omega = " + omega + " od.omega_lc=" + od.omega_lc + " od:" + od.LogString());
            Assert.IsTrue(FloatEqual(omega, od.omega_lc, 0.4));
        }
    }
Exemplo n.º 7
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 (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));
                }
            }
        }
    }
    // Check eccentricity and inclination
    public void EccentricityInclTest()
    {
        const float    mass        = 1000f;
        GameObject     star        = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        NBody          starNbody   = star.GetComponent <NBody>();
        const float    orbitRadius = 10f;
        GameObject     planet      = TestSetupUtils.CreatePlanetInOrbitUniversal(starNbody, 1f, orbitRadius);
        OrbitUniversal orbitU      = planet.GetComponent <OrbitUniversal>();

        float eccentricity = 0.3f;

        // MUST reset the scale after ecc is changed, since -> p
        orbitU.eccentricity = eccentricity;
        orbitU.SetMajorAxisInspector(orbitRadius);
        TestSetupUtils.SetupGravityEngine(star, planet);

        // Try some values of inclination and ecc
        float[] eccValues         = { 0f, .1f, .2f, 0.5f, 0.9f };
        float[] inclinationValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f };

        foreach (float inc in inclinationValues)
        {
            foreach (float ecc in eccValues)
            {
                Debug.Log("====EccentricityInclTest====    ecc=" + ecc + " incl = " + inc);
                orbitU.inclination  = inc;
                orbitU.eccentricity = ecc;
                orbitU.SetMajorAxisInspector(orbitRadius);      // can only use for ellipses
                TestSetupUtils.SetupGravityEngine(star, planet);
                OrbitData od = new OrbitData();
                od.SetOrbitForVelocity(planet.GetComponent <NBody>(), starNbody);
                Debug.Log("TEST: incl = " + orbitU.inclination + " ecc=" + orbitU.eccentricity + " od:" + od.LogString());
                Debug.LogFormat("Check ecc: {0} vs {1}", ecc, od.ecc);
                Assert.IsTrue(GEUnit.FloatEqual(ecc, od.ecc, 1E-3));
                float axis = (float)orbitU.GetMajorAxisInspector();
                Debug.LogFormat("Check axis: {0} vs {1}", axis, od.a);
                Assert.IsTrue(GEUnit.FloatEqual(axis, od.a, 1E-3));
                Debug.LogFormat("Check incl: {0} vs {1}", inc, od.inclination);
                Assert.IsTrue(GEUnit.FloatEqual(inc, od.inclination, 1E-3));
                // TestRV(od, planet, starNbody, orbitRadius);
            }
        }
    }
Exemplo n.º 9
0
    // Check eccentricity and inclination
    public void EllipseInclination()
    {
        const float  mass         = 1000f;
        GameObject   star         = TestSetupUtils.CreateNBody(mass, new Vector3(0, 0, 0));
        const float  orbitRadius  = 10f;
        GameObject   planet       = TestSetupUtils.CreatePlanetInOrbit(star, 1f, orbitRadius);
        OrbitEllipse orbitEllipse = planet.GetComponent <OrbitEllipse>();

        float eccentricity = 0.3f;

        orbitEllipse.ecc = eccentricity;
        TestSetupUtils.SetupGravityEngine(star, planet);

        // take the velocity and check
        OrbitData orbitData = new OrbitData();

        orbitData.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
        Assert.IsTrue(FloatEqual(orbitRadius, orbitData.a));
        Assert.IsTrue(FloatEqual(eccentricity, orbitData.ecc));

        // Try some values of inclination
        float[] inclinationValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f };
        foreach (float inc in inclinationValues)
        {
            Debug.Log("====EclipseInclination====    inc=" + inc);
            orbitEllipse.inclination = inc;
            TestSetupUtils.SetupGravityEngine(star, planet);
            OrbitData od = new OrbitData();
            od.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>());
            Debug.Log("TEST: incl = " + orbitEllipse.inclination + " ecc=" + orbitEllipse.ecc + " od:" + od.LogString());
            Assert.IsTrue(FloatEqual(inc, od.inclination));
            TestRV(od, planet, star, orbitRadius);
        }
    }