public GridPositionModel GetGridPosition(int v1X, int v1Y, int v2X, int v2Y, int v3X, int v3Y)
        {
            TrigonometryCalculator calc  = new TrigonometryCalculator();
            GridPositionModel      model = new GridPositionModel(calc.GetGridPosition(new TriangleCoordinates(v1X, v1Y, v2X, v2Y, v3X, v3Y)));

            return(model);
        }
예제 #2
0
        public static void GetGridPosition()
        {
            // F11
            TriangleCoordinates coordinates1 = new TriangleCoordinates(50, 60, 50, 50, 60, 60);
            GridPosition        position1    = _calc.GetGridPosition(coordinates1);

            Assert.AreEqual(position1.Row, "F");
            Assert.AreEqual(position1.Column, 11);

            // A1
            TriangleCoordinates coordinates2 = new TriangleCoordinates(0, 10, 0, 0, 10, 10);
            GridPosition        position2    = _calc.GetGridPosition(coordinates2);

            Assert.AreEqual(position2.Row, "A");
            Assert.AreEqual(position2.Column, 1);

            // A2
            TriangleCoordinates coordinates3 = new TriangleCoordinates(10, 0, 0, 0, 10, 10);
            GridPosition        position3    = _calc.GetGridPosition(coordinates3);

            Assert.AreEqual(position3.Row, "A");
            Assert.AreEqual(position3.Column, 2);

            // B4
            TriangleCoordinates coordinates4 = new TriangleCoordinates(20, 10, 10, 10, 20, 20);
            GridPosition        position4    = _calc.GetGridPosition(coordinates4);

            Assert.AreEqual(position4.Row, "B");
            Assert.AreEqual(position4.Column, 4);

            // F12
            TriangleCoordinates coordinates5 = new TriangleCoordinates(60, 50, 50, 50, 60, 60);
            GridPosition        position5    = _calc.GetGridPosition(coordinates5);

            Assert.AreEqual(position5.Row, "F");
            Assert.AreEqual(position5.Column, 12);

            // B3
            TriangleCoordinates coordinates6 = new TriangleCoordinates(10, 20, 10, 10, 20, 20);
            GridPosition        position6    = _calc.GetGridPosition(coordinates6);

            Assert.AreEqual(position6.Row, "B");
            Assert.AreEqual(position6.Column, 3);
        }