Exemplo n.º 1
0
        internal override bool isCross(GeoRect SelectPoint)
        {
            if (NodesCount < 2)
            {
                return(false);
            }
            GeoPoint A = new GeoPoint((SelectPoint.Xmax + SelectPoint.Xmin) / 2,
                                      (SelectPoint.Ymax + SelectPoint.Ymin) / 2);
            GeoPoint B = new GeoPoint(Bounds.Xmin + 1, (SelectPoint.Ymax + SelectPoint.Ymin) / 2);
            int      k = 0;

            if (GeoRect.isIntersect(Bounds, SelectPoint))
            {
                for (int i = 0; i < Nodes.Count - 1; i++)
                {
                    if (GeoRect.IsCrosLines(A, B, Nodes[i], Nodes[i + 1]) &&
                        A.y != Nodes[i].y &&
                        Nodes[i].y != Nodes[i + 1].y)
                    {
                        k++;
                    }
                }
                if ((k % 2) == 1)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        public static GeoRect Union(GeoRect A, GeoRect B)
        {
            if (!A.isCucumber)
            {
                return(B);
            }
            if (!B.isCucumber)
            {
                return(A);
            }
            GeoRect result = new GeoRect(Math.Min(A.Xmax, B.Xmax),
                                         Math.Max(A.Xmin, B.Xmin),
                                         Math.Min(A.Ymin, B.Ymin),
                                         Math.Max(A.Ymax, B.Ymax));

            return(result);
        }
Exemplo n.º 3
0
        public static bool isIntersect(GeoRect A, GeoRect B)
        {
            //yay!
            if ((B.Xmax >= A.Xmax && B.Xmax <= A.Xmin && B.Ymax <= A.Ymax && B.Ymax >= A.Ymin) ||
                (B.Xmin >= A.Xmax && B.Xmin <= A.Xmin && B.Ymin <= A.Ymax && B.Ymin >= A.Ymin) ||
                (B.Xmax >= A.Xmax && B.Xmax <= A.Xmin && B.Ymin <= A.Ymax && B.Ymin >= A.Ymin) ||
                (B.Xmin >= A.Xmax && B.Xmin <= A.Xmin && B.Ymax <= A.Ymax && B.Ymax >= A.Ymin)
                )
            {
                return(true);
            }

            if ((A.Xmax >= B.Xmax && A.Xmax <= B.Xmin && A.Ymax <= B.Ymax && A.Ymax >= B.Ymin) ||
                (A.Xmin >= B.Xmax && A.Xmin <= B.Xmin && A.Ymin <= B.Ymax && A.Ymin >= B.Ymin) ||
                (A.Xmax >= B.Xmax && A.Xmax <= B.Xmin && A.Ymin <= B.Ymax && A.Ymin >= B.Ymin) ||
                (A.Xmin >= B.Xmax && A.Xmin <= B.Xmin && A.Ymax <= B.Ymax && A.Ymax >= B.Ymin)
                )
            {
                return(true);
            }

            return(false);
        }