public GridWorld(QuadTree space, IntVec2 resolution = null)
        {
            if (resolution == null)
            {
                resolution = new IntVec2(100, 100);
            }
            this.colCount = resolution.x;
            this.rowCount = resolution.z;
            this.space    = space;
            int width  = this.space.Width;
            int height = this.space.Height;

            xInterval = width / resolution.x;
            zInterval = height / resolution.z;

            V   = resolution.x * resolution.z;
            s   = new int[V];
            adj = new List <DirectedWeightedEdge> [V];
            for (int i = 0; i < V; ++i)
            {
                s[i]   = i;
                adj[i] = new List <DirectedWeightedEdge>();
            }

            for (int i = 0; i < this.rowCount; ++i)
            {
                for (int j = 0; j < this.colCount; ++j)
                {
                    int v = i * this.colCount + j;
                    for (int ii = -1; ii <= 1; ++ii)
                    {
                        for (int jj = -1; jj <= 1; ++jj)
                        {
                            int w = (i + ii) * this.colCount + (j + jj);
                            if (w == v)
                            {
                                continue;
                            }
                            if (w < 0 || w >= V)
                            {
                                continue;
                            }
                            Connect(w, v);
                        }
                    }
                }
            }
        }
        public static int SidenessTest(IntVec2 A, IntVec2 B, IntVec2 C)
        {
            int result = (B.x - A.x) * (C.z - A.z) - (B.z - A.z) * (C.x - A.x);

            if (result == 0)
            {
                return(0);
            }
            else if (result > 0)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
 public static int dotProduct(IntVec2 lhs, IntVec2 rhs)
 {
     return(lhs.x * rhs.x + lhs.z * rhs.z);
 }
 public int CrossLength(IntVec2 v)
 {
     return(Math.Abs(x * v.z - z * v.x));
 }
 public int dotProduct(IntVec2 rhs)
 {
     return(mX * rhs.x + mZ * rhs.z);
 }