diff --git a/app/src/main/java/src/univ/CelestialBody.java b/app/src/main/java/src/univ/CelestialBody.java index 9273c097..7e6e0979 100644 --- a/app/src/main/java/src/univ/CelestialBody.java +++ b/app/src/main/java/src/univ/CelestialBody.java @@ -87,11 +87,20 @@ public double orbitalVelocity(double r2) return Math.sqrt((G*mass)/r); } - public double acceleration() + /** + * Calculates the gravitational acceleration of a planet + * @return acceleration in m/s^2 + */ + public double planetaryGravitationalAcceleration() { double G = 6.67408e-11; return (G*mass)/(radius*radius); } + /** + * Calculates the orbital period of a planet + * @param r2 The height of the orbit above the planet's surface (meters) + * @return time (seconds) it takes for an object to orbit once around another object + */ public double orbitalPeriod(double r2) { double G = 6.67408e-11; diff --git a/app/src/test/java/src/test/TestCelestialBody.java b/app/src/test/java/src/test/TestCelestialBody.java index ef4f2bed..eb594cef 100644 --- a/app/src/test/java/src/test/TestCelestialBody.java +++ b/app/src/test/java/src/test/TestCelestialBody.java @@ -136,15 +136,14 @@ void testOrbitalVelocity() } /* Tests that the acceleration() method calculates the gravitational acceleration of the earth correctly*/ @Test - void testAcceleration() + void testPlanetaryGravitationalAcceleration() { /*Earth's gravitational acceleration*/ double exactAcceleration = 9.8; /*Test*/ CelestialBody earth = new CelestialBody(new Vector3d(), new Vector3d(), 5.97*Math.pow(10,24), 6378000, "Earth", "", "", LocalDateTime.of(d1, t1)); - double testAcceleration = earth.acceleration(); - System.out.println(testAcceleration); + double testAcceleration = earth.planetaryGravitationalAcceleration(); assertTrue(inRange(exactAcceleration, testAcceleration, epsilon)); } /* Tests that the orbitalPeriodMethod() method calculates the orbital period of the earth around the sun correctly*/ @@ -162,7 +161,6 @@ void testOrbitalPeriod() /*Test*/ double testOrbitalPeriod = sun.orbitalPeriod(r2); - System.out.println(testOrbitalPeriod); assertTrue(inRange(exactOrbitalPeriod, testOrbitalPeriod, epsilon)); } /**