Exemplo n.º 1
0
 public void TestArcTan2()
 {
     for (Double x = -10f; x <= 10f; x += 1f)
     {
         for (Double y = -10f; y <= 10f; y += 1f)
         {
             Fixed32 fx       = x;
             Fixed32 fy       = y;
             Fixed32 fs       = Fixed32.ArcTan2(fy, fx);
             Double  result   = fs.ToDouble();
             Double  expected = Math.Atan2(y, x);
             Assert.That(result,
                         Is.EqualTo(expected).Within(MathsTests.TestTolerance).                           // Check that result is within test tolerance for Fixed32
                         Or.EqualTo(expected).Within(MathsTests.PercentageTolerance * Math.Abs(result))); // or that result is within test percentage for Fixed32.
         }
     }
 }