public void TestGravitationalMovement() { Acceleration2D testAcceleration = new Acceleration2D(new Vector2D(5.0, 0.0), 200.0); Velocity2D testVelosity = new Velocity2D(5.0, 36.86989764584402); Movement testMovement = new GravitationalMovement(testVelosity, testAcceleration); Point2D testPoint = new Point2D(0.0, 0.0); double[] expectedX = new double[] { 8.0, 20.0, 36.0, 56.0, 80.0, 108.0, 140.0, 176.0, 216.0, 260.0 }; double[] expectedY = new double[] { 6.0, 15.0, 27.0, 42.0, 60.0, 81.0, 105.0, 132.0, 162.0, 195.0 }; for (int i = 0; i < 10; i++) { testMovement.Step(); testPoint.X += testMovement.DeltaX; testPoint.Y += testMovement.DeltaY; Assert.AreEqual(expectedX[i], testPoint.X, "failure with x on iteration " + i); Assert.AreEqual(expectedY[i], testPoint.Y, "failure with y on iteration " + i); } }
/// <summary> /// GravitationalMovement Constructor, sets inital values for velosity and acceleration. /// </summary> /// <param name="velocity"></param> /// <param name="acceleration"></param> public GravitationalMovement(Velocity2D velocity, Acceleration2D acceleration) : base(velocity) { _acceleration = acceleration; }