示例#1
0
    private static void AssertConsistent(Basis basis, double angle, Dir dir)
    {
        var eps = Turn.OneTurnClockwise * 0.00001;
        Assert.IsTrue(basis.AngleToDir(angle).Equals(dir, eps));
        Assert.IsTrue(Dir.FromAngle(angle, basis).Equals(dir, eps));
        Assert.AreEqual(basis.DirToUnsignedAngle(dir), angle, 0.00001);
        Assert.AreEqual(dir.GetUnsignedAngle(basis), angle, 0.00001);

        var u = Math.Abs(basis.UnitsPerCounterClockwiseTurn);
        var s = angle * 2 >= u ? angle - u : angle;
        var r = basis.DirToSignedAngle(dir);
        Assert.AreEqual(r, dir.GetSignedAngle(basis));
        if ((Math.Abs(s - u / 2) > 0.01 || Math.Abs(r + u / 2) > 0.01) && (Math.Abs(s + u / 2) > 0.01 || Math.Abs(r - u / 2) > 0.01)) {
            Assert.AreEqual(r, s, 0.00001);
        }
    }