Esempio n. 1
0
        public void GetPerpendicularPointsCanGetThemForXAxis()
        {
            /*
             * Visualization of the MapGrid.
             * t = traveler
             * z = zone border
             * -------------------------------
             |     |     |     |     |  z  |
             | -------------------------------
             |     |     |     |     |  z  |
             | -------------------------------
             |     |     | 0,0 |  t  |  z  |
             | -------------------------------
             |     |     |     |     |  z  |
             | -------------------------------
             |     |     |     |     |  z  |
             | -------------------------------
             */
            var want = new List <Vector3>
            {
                new Vector3(2, 0, 1),
                new Vector3(2, 0, 2),
                new Vector3(2, 0, -1),
                new Vector3(2, 0, -2)
            };


            var from = new Vector3(1, 0, 0);
            var to   = new Vector3(2, 0, 0);

            List <Vector3> got = GridMath.GetPerpendicularPoints(from, to, 2);

            Assert.Equal(want.Count, got.Count);
            // Fluent Assertions don't care about order.
            want.Should().BeEquivalentTo(got);
        }
Esempio n. 2
0
        public void GetPerpendicularPointsCanDoDiagonalPointsWithSameDiff(int fromX, int fromY)
        {
            /*
             * Visualization of the MapGrid.
             * t = traveler
             * z = zone border
             * -------------------------------
             |  z  |     |     |     |     |
             | -------------------------------
             |     |  z  |     |  t2 |     |
             | -------------------------------
             |     |     |  z  |     |     |
             | -------------------------------
             |     |  t1 |     |  z  |     |
             | -------------------------------
             |     |     |     |     |  z  |
             | -------------------------------
             */
            var want = new List <Vector3>
            {
                new Vector3(-2, 0, 2),
                new Vector3(-1, 0, 1),
                new Vector3(1, 0, -1),
                new Vector3(2, 0, -2),
            };


            var from = new Vector3(fromX, 0, fromY);
            var to   = new Vector3(0, 0, 0);

            List <Vector3> got = GridMath.GetPerpendicularPoints(from, to, 2);

            Assert.Equal(want.Count, got.Count);
            // Fluent Assertions don't care about order.
            got.Should().BeEquivalentTo(want);
        }