Beispiel #1
0
 private static void AssertConsistent(Basis basis, double angle, Turn turn)
 {
     var eps = Turn.OneTurnClockwise * 0.00001;
     Assert.IsTrue(basis.AngleToTurn(angle).Equals(turn, eps));
     Assert.IsTrue(Turn.FromAngle(angle, basis).Equals(turn, eps));
     Assert.AreEqual(basis.TurnToAngle(turn), angle, 0.00001);
     Assert.AreEqual(turn.GetAngle(basis), angle, 0.00001);
 }
Beispiel #2
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);
        }
    }