public void NodeGridWrapperTest()
        {
            ICoordinate[,] coordinates = new ICoordinate[4, 3];
            coordinates[0, 0]          = new Coordinate(0, 0);
            coordinates[1, 0]          = new Coordinate(1, 0);
            coordinates[2, 0]          = new Coordinate(2, 0);
            coordinates[3, 0]          = new Coordinate(3, 0);

            coordinates[0, 1] = new Coordinate(0, 1);
            coordinates[1, 1] = new Coordinate(1.2, 1.1);
            coordinates[2, 1] = new Coordinate(2.4, 1.2);
            coordinates[3, 1] = new Coordinate(3.8, 1.3);

            coordinates[0, 2] = new Coordinate(0, 2);
            coordinates[1, 2] = new Coordinate(1.3, 2.1);
            coordinates[2, 2] = new Coordinate(2.9, 2.2);
            coordinates[3, 2] = new Coordinate(4.5, 2.3);

            Spatial2DCurveLinearGrid grid = new Spatial2DCurveLinearGrid()
            {
                Coordinates = coordinates,
                IsNodeBased = true,
            };

            Spatial2DGridWrapper wrapper = new Spatial2DGridWrapper(grid);

            Assert.AreEqual(ElementType.Point, wrapper.ElementType);
            Assert.AreEqual(12, wrapper.ElementCount);

            Assert.AreEqual(1, wrapper.GetVertexCount(0));
            Assert.AreEqual(1, wrapper.GetVertexCount(3));
            Assert.AreEqual(1, wrapper.GetVertexCount(8));
            Assert.AreEqual(1, wrapper.GetVertexCount(11));

            Assert.AreEqual(0, wrapper.GetVertexXCoordinate(0, 0));
            Assert.AreEqual(0, wrapper.GetVertexYCoordinate(0, 0));

            Assert.AreEqual(3, wrapper.GetVertexXCoordinate(3, 0));
            Assert.AreEqual(0, wrapper.GetVertexYCoordinate(3, 0));

            Assert.AreEqual(0, wrapper.GetVertexXCoordinate(8, 0));
            Assert.AreEqual(2, wrapper.GetVertexYCoordinate(8, 0));

            Assert.AreEqual(2.9, wrapper.GetVertexXCoordinate(10, 0));
            Assert.AreEqual(2.2, wrapper.GetVertexYCoordinate(10, 0));
        }
        public void NodeGridWrapperTest()
        {
            Spatial2DRegularGrid grid = new Spatial2DRegularGrid
            {
                X0          = 10,
                Y0          = 20,
                Dx          = 2,
                Dy          = 4,
                XCount      = 4,
                YCount      = 3,
                Orientation = 30,
                IsNodeBased = true,
            };

            Spatial2DGridWrapper gridWrapper = new Spatial2DGridWrapper(grid);

            double rotxx = Math.Cos(30.0 / 180.0 * Math.PI);
            double rotxy = Math.Sin(30.0 / 180.0 * Math.PI);
            double rotyx = -Math.Sin(30.0 / 180.0 * Math.PI);
            double rotyy = Math.Cos(30.0 / 180.0 * Math.PI);

            Assert.AreEqual(ElementType.Point, gridWrapper.ElementType);
            Assert.AreEqual(12, gridWrapper.ElementCount);

            Assert.AreEqual(1, gridWrapper.GetVertexCount(0));
            Assert.AreEqual(1, gridWrapper.GetVertexCount(3));
            Assert.AreEqual(1, gridWrapper.GetVertexCount(8));
            Assert.AreEqual(1, gridWrapper.GetVertexCount(11));

            Assert.AreEqual(10, gridWrapper.GetVertexXCoordinate(0, 0));
            Assert.AreEqual(20, gridWrapper.GetVertexYCoordinate(0, 0));

            Assert.AreEqual(10 + rotxx * 6, gridWrapper.GetVertexXCoordinate(3, 0));              // 15.19
            Assert.AreEqual(20 + rotyx * 6, gridWrapper.GetVertexYCoordinate(3, 0));              // 17

            Assert.AreEqual(10 + rotxy * 8, gridWrapper.GetVertexXCoordinate(8, 0));              // 14
            Assert.AreEqual(20 + rotyy * 8, gridWrapper.GetVertexYCoordinate(8, 0));              // 26.92

            Assert.AreEqual(10 + rotxx * 6 + rotxy * 8, gridWrapper.GetVertexXCoordinate(11, 0)); // 19,19
            Assert.AreEqual(20 + rotyx * 6 + rotyy * 8, gridWrapper.GetVertexYCoordinate(11, 0)); // 23.92
        }
        public void ElmtGridWrapperTest()
        {
            Spatial2DRegularGrid grid = new Spatial2DRegularGrid
            {
                X0          = 10,
                Y0          = 20,
                Dx          = 2,
                Dy          = 4,
                XCount      = 4,
                YCount      = 3,
                Orientation = 30,
                IsNodeBased = false,
            };

            Spatial2DGridWrapper gridWrapper = new Spatial2DGridWrapper(grid);

            double rotxx = Math.Cos(30.0 / 180.0 * Math.PI);
            double rotxy = Math.Sin(30.0 / 180.0 * Math.PI);
            double rotyx = -Math.Sin(30.0 / 180.0 * Math.PI);
            double rotyy = Math.Cos(30.0 / 180.0 * Math.PI);

            Assert.AreEqual(ElementType.Polygon, gridWrapper.ElementType);
            Assert.AreEqual(12, gridWrapper.ElementCount);

            Assert.AreEqual(4, gridWrapper.GetVertexCount(0));
            Assert.AreEqual(4, gridWrapper.GetVertexCount(3));
            Assert.AreEqual(4, gridWrapper.GetVertexCount(8));
            Assert.AreEqual(4, gridWrapper.GetVertexCount(11));

            // Check first element
            Assert.AreEqual(10, gridWrapper.GetVertexXCoordinate(0, 0));
            Assert.AreEqual(20, gridWrapper.GetVertexYCoordinate(0, 0));
            Assert.AreEqual(10 + rotxx * 2, gridWrapper.GetVertexXCoordinate(0, 1));
            Assert.AreEqual(20 + rotyx * 2, gridWrapper.GetVertexYCoordinate(0, 1));
            Assert.AreEqual(10 + rotxx * 2 + rotxy * 4, gridWrapper.GetVertexXCoordinate(0, 2));
            Assert.AreEqual(20 + rotyx * 2 + rotyy * 4, gridWrapper.GetVertexYCoordinate(0, 2));
            Assert.AreEqual(10 + rotxy * 4, gridWrapper.GetVertexXCoordinate(0, 3));
            Assert.AreEqual(20 + rotyy * 4, gridWrapper.GetVertexYCoordinate(0, 3));

            // Check last element
            Assert.AreEqual(10 + rotxx * 6 + rotxy * 8, gridWrapper.GetVertexXCoordinate(11, 0));  // 19,19
            Assert.AreEqual(20 + rotyx * 6 + rotyy * 8, gridWrapper.GetVertexYCoordinate(11, 0));  // 23.92
            Assert.AreEqual(10 + rotxx * 8 + rotxy * 8, gridWrapper.GetVertexXCoordinate(11, 1));  // 20.92
            Assert.AreEqual(20 + rotyx * 8 + rotyy * 8, gridWrapper.GetVertexYCoordinate(11, 1));  // 22.92
            Assert.AreEqual(10 + rotxx * 8 + rotxy * 12, gridWrapper.GetVertexXCoordinate(11, 2)); // 22.92
            Assert.AreEqual(20 + rotyx * 8 + rotyy * 12, gridWrapper.GetVertexYCoordinate(11, 2)); // 26.39
            Assert.AreEqual(10 + rotxx * 6 + rotxy * 12, gridWrapper.GetVertexXCoordinate(11, 3)); // 21.19
            Assert.AreEqual(20 + rotyx * 6 + rotyy * 12, gridWrapper.GetVertexYCoordinate(11, 3)); // 27.39
        }