コード例 #1
0
    public void TestLerp()
    {
        //Tests.EqualHex("hex_round 1", new Hex(5, -10, 5), FractionalHex.HexRound(FractionalHex.HexLerp(new FractionalHex(0, 0, 0), new FractionalHex(10, -20, 10), 0.5)));
        //Tests.EqualHex("hex_round 2", FractionalHex.HexRound(a), FractionalHex.HexRound(FractionalHex.HexLerp(a, b, 0.499)));
        //Tests.EqualHex("hex_round 3", FractionalHex.HexRound(b), FractionalHex.HexRound(FractionalHex.HexLerp(a, b, 0.501)));
        CoordDouble a = new CoordDouble(0, 0, 0);
        CoordDouble b = new CoordDouble(1, -1, 0);

        Assert.That(new CoordDouble(0, 0, 0).Lerp(new CoordDouble(10, -20, 10), 0.5).Round(),
                    Is.EqualTo(new Coord(5, -10, 5)));
        Assert.That(a.Lerp(b, 0.499).Round(), Is.EqualTo(a.Round()));
        Assert.That(a.Lerp(b, 0.501).Round(), Is.EqualTo(b.Round()));
    }