コード例 #1
0
        public void PointSubtractionFloat()
        {
            var a = new Point <float>(.1f, .1f);
            var b = new Point <float>(.2f, .2f);

            Assert.AreEqual(PointUtil.Subtract(a, b), new Point <float>(-.1f, -.1f));
            Assert.AreEqual(PointUtil.Subtract(a, .2f), new Point <float>(-.1f, -.1f));
        }
コード例 #2
0
        public void PointSubtractionInt()
        {
            var a = new Point <int>(1, 1);
            var b = new Point <int>(2, 2);

            Assert.AreEqual(PointUtil.Subtract(a, b), new Point <int>(-1, -1));
            Assert.AreEqual(PointUtil.Subtract(a, 2), new Point <int>(-1, -1));
        }
コード例 #3
0
        public void FindShouldFind()
        {
            var layer = new Layer <int>(PointUtil.Subtract(PointUtil.zero, 5), PointUtil.Add(PointUtil.zero, 5));

            layer.Set(-5, -5, 2112);
            layer.Set(4, 4, 2113);

            Assert.AreEqual(new Point <int>(-5, -5), layer.Find(2112));
        }
コード例 #4
0
    static void TestPoint()
    {
        var a = new Point <int>(0, 0);
        var b = new Point <int>(2, 2);

        var c = new Point <float>(2.5f, 3.5f);
        var d = new Point <float>(1, 2);

        Console.WriteLine("IEquatable (should be true): " + (new Point <int>(2, 2) == b));
        Console.WriteLine("IEquatable (should be false): " + (a == b));
        Console.WriteLine("Copy (should be true): " + (new Point <int>(b) == b));
        Console.WriteLine("Addition ({0}) ({1})", PointUtil.Add(a, b), PointUtil.Add(c, d));
        Console.WriteLine("Addition ({0}) ({1})", PointUtil.Add(a, 3), PointUtil.Add(c, 3.5f));
        Console.WriteLine("Subtraction ({0}) ({1})", PointUtil.Subtract(a, b), PointUtil.Subtract(c, d));
        Console.WriteLine("Subtraction ({0}) ({1})", PointUtil.Subtract(a, 3), PointUtil.Subtract(c, 3.5f));
        Console.WriteLine("Multiplication ({0}) ({1})", PointUtil.Multiply(a, b), PointUtil.Multiply(c, d));
        Console.WriteLine("Multiplication ({0}) ({1})", PointUtil.Multiply(b, 3), PointUtil.Multiply(c, 3));
        Console.WriteLine("Division ({0}) ({1})", PointUtil.Divide(b, b), PointUtil.Divide(c, d));
        Console.WriteLine("Division ({0}) ({1})", PointUtil.Divide(b, 2), PointUtil.Divide(c, 10));
    }