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); } }
// Create an NBody and check it's mass public void EccentricityPrediction() { 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>(); OrbitPredictor op = TestSetupUtils.AddOrbitPredictor(planet, star); Assert.NotNull(op); double[] ecc_values = { 0, 0.1, 0.7, 0.9, 0.99, 1.01, 1.5, 2 }; foreach (double ecc in ecc_values) { Debug.LogFormat("#### EccentricityPrediction ecc={0}", ecc); orbitU.eccentricity = ecc; TestSetupUtils.SetupGravityEngine(star, planet); op.TestRunnerSetup(); OrbitUniversal predictedOrbit = op.GetOrbitUniversal(); Assert.NotNull(predictedOrbit); CompareOrbits(orbitU, predictedOrbit, small); } }
// Check eccentricity and inclination public void RVtoCOEtoRV() { GameObject star = TestSetupUtils.CreateNBody(10, new Vector3(0, 0, 0)); TestSetupUtils.SetupGravityEngine(star, null); NBody starBody = star.GetComponent <NBody>(); RVpair[] rvp = { new RVpair(10, 0, 0, 0, 1, 0), new RVpair(10, 0, 0, 0, 10, 0), new RVpair(10, 0, 0, 0, -1, 0), new RVpair(10, 0, 0, 0, -10, 0), new RVpair(-10, 10, 0, -4, 3, 0), new RVpair(-10, 10, 0, 4, -3, 0) }; for (int i = 0; i < rvp.Length; i++) { OrbitUtils.OrbitElements oe = OrbitUtils.RVtoCOE(rvp[i].r, rvp[i].v, starBody, false); Vector3d r1 = new Vector3d(); Vector3d v1 = new Vector3d(); OrbitUtils.COEtoRV(oe, starBody, ref r1, ref v1, false); Debug.LogFormat("i={0} r_in={1} r_out={2}\n v_in={3} v_out={4}\n oe: {5}", i, rvp[i].r, r1, rvp[i].v, v1, oe); Assert.IsTrue(GEUnit.Vec3dEqual(rvp[i].r, r1, small)); Assert.IsTrue(GEUnit.Vec3dEqual(rvp[i].v, v1, small)); } }
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); } } }
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)); } }
// 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); } }
public void KeplerVsTimeOfFlight() { // Need to make sure TOF < 1 period const float mass = 100f; 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>(); // Parabola (ecc=1.0 fails, need to investigate) float[] ecc_values = { 0.0f, 0.1f, 0.5f, 0.9f, 1.2f, 1.5f }; foreach (float ecc in ecc_values) { Debug.LogFormat("======= ecc={0} =======", ecc); orbitU.eccentricity = ecc; orbitU.p = 10f; orbitU.evolveMode = OrbitUniversal.EvolveMode.KEPLERS_EQN; // Evolve to position r1 double time = 5.0; TestSetupUtils.SetupGravityEngine(star, planet); double[] r1 = new double[] { 0, 0, 0 }; // orbitU.PreEvolve(pscale, mscale); // Ugh. Need to do this before call evolve, since it caches the value. Vector3d r0_vec = GravityEngine.Instance().GetPositionDoubleV3(planet.GetComponent <NBody>()); orbitU.Evolve(time, ref r1); Vector3d r1_vec = new Vector3d(ref r1); // check time to r1 double time_test = orbitU.TimeOfFlight(r0_vec, r1_vec); Debug.LogFormat("check r0={0} to r1={1} p ={2} after t={3} TOF => {4}", r0_vec, r1_vec, orbitU.p, time, time_test); Assert.IsTrue(GEUnit.DoubleEqual(time, time_test, 1E-4)); } }
public void PositionForRadius() { 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.inclination = 5; orbitU.SetMajorAxisInspector(orbitRadius); float r = 10.0f; float[] eccValues = { 0f, 0.1f, 0.9f, 1.1f }; foreach (float ecc in eccValues) { Debug.LogFormat("======= ecc={0} =======", ecc); orbitU.eccentricity = ecc; orbitU.SetMajorAxisInspector(orbitRadius); // updates p TestSetupUtils.SetupGravityEngine(star, planet); Vector3[] positions = orbitU.GetPositionsForRadius(r, new Vector3(0, 0, 0)); Debug.LogFormat("pos[0]={0} pos[1]={1}", positions[0], positions[1]); foreach (Vector3 p in positions) { Debug.LogFormat("Position error={0}", Mathf.Abs(p.magnitude - r)); Assert.IsTrue(GEUnit.FloatEqual(p.magnitude, r, 1E-2)); } } }
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 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)); } }
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); } }
public void OmegasEllipseInclination() { 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 = 35f; orbitEllipse.ecc = 0.25f; orbitEllipse.Init(); orbitEllipse.ApplyScale(1f); orbitEllipse.InitNBody(1f, 1f); // Try some values of om float[] omegaValues = { 0f, 30f, 45f, 60f, 90f, 135f, 180f }; 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>()); TestRV(od, planet, star, orbitRadius); } }
public void PhaseRetrogradeEllipse() { 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.4f; orbitEllipse.inclination = 180f; // Try some values of om float[] phaseValues = { 30f, 45f, 60f, 90f, 135f, 180f, 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>()); Debug.Log("phase = " + phase + " od.phase=" + od.phase); // Need a bit of leeway at 0 with error Assert.IsTrue(FloatEqual(phase, od.phase, 0.02)); TestRV(od, planet, star, orbitRadius); } }
// Create an NBody and check it's mass public void CirclePrediction() { 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>(); OrbitPredictor op = TestSetupUtils.AddOrbitPredictor(planet, star); Assert.NotNull(op); double[] p_values = { 10, 100, 1000 }; foreach (double p in p_values) { Debug.LogFormat("#### CirclePrediction p={0}", p); orbitU.p = p; TestSetupUtils.SetupGravityEngine(star, planet); op.TestRunnerSetup(); OrbitUniversal predictedOrbit = op.GetOrbitUniversal(); Assert.NotNull(predictedOrbit); CompareOrbits(orbitU, predictedOrbit, small); } }
// Create an NBody and check it's mass public void OmegaUEllipsePrediction() { 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>(); // Need a bit of incl, otherwise omegaU comes back as omegaL. orbitU.inclination = 10; orbitU.eccentricity = 0.05; OrbitPredictor op = TestSetupUtils.AddOrbitPredictor(planet, star); Assert.NotNull(op); double[] ou_values = { 0, 1, 5, 10, 30, 60, 90, 180, 270, 355, 360 }; foreach (double ou in ou_values) { Debug.LogFormat("#### OmegaUPrediction ou={0}", ou); orbitU.omega_uc = ou; TestSetupUtils.SetupGravityEngine(star, planet); op.TestRunnerSetup(); OrbitUniversal predictedOrbit = op.GetOrbitUniversal(); Assert.NotNull(predictedOrbit); CompareOrbits(orbitU, predictedOrbit, small); } }
// Create an NBody and check it's mass public void InclinationPrediction() { 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>(); OrbitPredictor op = TestSetupUtils.AddOrbitPredictor(planet, star); Assert.NotNull(op); double[] incl_values = { 0, 1, 5, 10, 30, 45, 60, 90, 145, 179, 180 }; foreach (double incl in incl_values) { Debug.LogFormat("#### InclinationPrediction incl={0}", incl); orbitU.inclination = incl; TestSetupUtils.SetupGravityEngine(star, planet); op.TestRunnerSetup(); OrbitUniversal predictedOrbit = op.GetOrbitUniversal(); Assert.NotNull(predictedOrbit); CompareOrbits(orbitU, predictedOrbit, small); } }
// Create an NBody and check it's mass public void CircleA() { 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); TestSetupUtils.SetupGravityEngine(star, planet); // confirm planet is in correct location Assert.AreEqual(Vector3.Distance(planet.transform.position, new Vector3(10f, 0f, 0)), 0); // take the velocity and check OrbitData orbitData = new OrbitData(); orbitData.SetOrbitForVelocity(planet.GetComponent <NBody>(), star.GetComponent <NBody>()); Assert.AreEqual(orbitData.a, orbitRadius); Assert.AreEqual(orbitData.omega_uc, 0f); }
// 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); } } }
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)); } }
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; 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("ecc = " + ecc + " od.ecc=" + od.ecc); // Need a bit of leeway at 0 with error Assert.IsTrue(FloatEqual(ecc, od.ecc, 0.02)); TestRV(od, planet, star); } }
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)); } } } }