/// <summary>
 ///
 /// </summary>
 /// <param name="cardinal"></param>
 /// <param name="cardinal2"></param>
 /// <param name="points"></param>
 /// <returns></returns>
 private double[] ExtrapolateDisplacement(PointInfoDisplacement cardinal, double[][] points)
 {
     if (cardinal != null && cardinal.Visible)
     {
         int      cardinalId = cardinal.id;
         double[] p          = points[cardinalId];
         if (p == null)
         {
             return(null);
         }
         else
         {
             return(cardinal.Displacement(p));
         }
     }
     else
     {
         return(null);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="points"></param>
        /// <param name="id"></param>
        /// <param name="numOfCols"></param>
        /// <param name="numOfRows"></param>
        public void AssignCardinalPoints(PointInfoDisplacement[] points, int id, int numOfCols, int numOfRows)
        {
            int n         = (numOfCols * numOfRows) - 1;
            int idModCols = id % numOfCols;

            int index;

            // north
            int north = CanGoNorth(id, n, numOfCols);

            if (north != -1)
            {
                this.pN = points[north];

                // north east
                index = CanGoEast(north, n, numOfCols, idModCols);
                if (index != -1)
                {
                    this.pNE = points[index];
                }
                // north west
                index = CanGoWest(north, n, numOfCols, idModCols);
                if (index != -1)
                {
                    this.pNW = points[index];
                }
                // second north
                int north2 = CanGoNorth(north, n, numOfCols);
                if (north2 != -1)
                {
                    this.p2N = points[north2];
                }
            }


            // south
            int south = CanGoSouth(id, n, numOfCols);

            if (south != -1)
            {
                this.pS = points[south];

                // south east
                index = CanGoEast(south, n, numOfCols, idModCols);
                if (index != -1)
                {
                    this.pSE = points[index];
                }
                // south west
                index = CanGoWest(south, n, numOfCols, idModCols);
                if (index != -1)
                {
                    this.pSW = points[index];
                }
                // second south
                int south2 = CanGoSouth(south, n, numOfCols);
                if (south2 != -1)
                {
                    this.p2S = points[south2];
                }
            }


            // east
            index = CanGoEast(id, n, numOfCols, idModCols);
            if (index != -1)
            {
                this.pE = points[index];
                // second east
                index = CanGoEast(index, n, numOfCols, idModCols);
                if (index != -1)
                {
                    this.p2E = points[index];
                }
            }

            // west
            index = CanGoWest(id, n, numOfCols, idModCols);
            if (index != -1)
            {
                this.pW = points[index];

                // second west
                index = CanGoWest(index, n, numOfCols, idModCols);
                if (index != -1)
                {
                    this.p2W = points[index];
                }
            }
        }