public void LengthAndDistance() { Random Rand = new Random(); Vector2D Test1 = new Vector2D(Rand.NextDouble() * 1000, Rand.NextDouble() * 1000); Vector2D Test2 = new Vector2D(Rand.NextDouble() * 1000, Rand.NextDouble() * 1000); Vector2D Test3 = Test1 + Test2; double Distance1 = Test2.GetLength(); double Distance2 = Vector2D.GetDistanceBetween(Test1, Test3); Assert.IsTrue(Distance1 < Distance2 + .001f && Distance1 > Distance2 - .001f); }
public void GetLengthAndNormalize() { Vector2D Point3 = new Vector2D(3, -4); Assert.IsTrue(Point3.GetLength() > 4.999f && Point3.GetLength() < 5.001f); Point3.Normalize(); Assert.IsTrue(Point3.GetLength() > 0.99f && Point3.GetLength() < 1.01f); }