Beispiel #1
0
        internal override bool isCross(GeoRect SelectPoint)
        {
            //4 проверки на пересечения прямоугольника и линии (со сторонами) + если внутри
            GeoPoint A = new GeoPoint(SelectPoint.Xmin, SelectPoint.Ymax);
            GeoPoint B = new GeoPoint(SelectPoint.Xmax, SelectPoint.Ymax);
            GeoPoint C = new GeoPoint(SelectPoint.Xmax, SelectPoint.Ymin);
            GeoPoint D = new GeoPoint(SelectPoint.Xmin, SelectPoint.Ymin);

            if (GeoRect.IsCrosLines(B, A, BeginPoint, EndPoint))
            {
                return(true);
            }
            if (GeoRect.IsCrosLines(C, B, BeginPoint, EndPoint))
            {
                return(true);
            }
            if (GeoRect.IsCrosLines(C, D, BeginPoint, EndPoint))
            {
                return(true);
            }
            if (GeoRect.IsCrosLines(D, A, BeginPoint, EndPoint))
            {
                return(true);
            }
            if (BeginPoint.x >= SelectPoint.Xmax && BeginPoint.x <= SelectPoint.Xmin &&
                BeginPoint.y <= SelectPoint.Ymax && BeginPoint.y >= SelectPoint.Ymin)
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        internal override bool isCross(GeoRect SelectPoint)
        {
            if (NodesCount < 2)
            {
                return(false);
            }


            GeoPoint A = new GeoPoint(SelectPoint.Xmin, SelectPoint.Ymax);
            GeoPoint B = new GeoPoint(SelectPoint.Xmax, SelectPoint.Ymax);
            GeoPoint C = new GeoPoint(SelectPoint.Xmax, SelectPoint.Ymin);
            GeoPoint D = new GeoPoint(SelectPoint.Xmin, SelectPoint.Ymin);

            for (int i = 0; i < Nodes.Count - 1; i++)
            {
                if (GeoRect.IsCrosLines(B, A, Nodes[i], Nodes[i + 1]))
                {
                    return(true);
                }
                if (GeoRect.IsCrosLines(C, B, Nodes[i], Nodes[i + 1]))
                {
                    return(true);
                }
                if (GeoRect.IsCrosLines(C, D, Nodes[i], Nodes[i + 1]))
                {
                    return(true);
                }
                if (GeoRect.IsCrosLines(D, A, Nodes[i], Nodes[i + 1]))
                {
                    return(true);
                }
                if (Nodes[i].x >= SelectPoint.Xmax && Nodes[i].x <= SelectPoint.Xmin &&
                    Nodes[i].y <= SelectPoint.Ymax && Nodes[i].y >= SelectPoint.Ymin)
                {
                    return(true);
                }
            }

            return(false);
        }