public override bool IsIntersects(Node searchpoint, double quad) { // checking with border is the same as a polyline Node p1 = new Node(searchpoint.X - quad, searchpoint.Y + quad); Node p2 = new Node(searchpoint.X + quad, searchpoint.Y + quad); Node p3 = new Node(searchpoint.X + quad, searchpoint.Y - quad); Node p4 = new Node(searchpoint.X - quad, searchpoint.Y - quad); Node begin; Node end; for (int i = 0; i < NodeCount - 1; i++) { begin = _nodes[i]; end = _nodes[i + 1]; if (Analysis.IsSegmentsIntersects(begin, end, p1, p2)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p2, p3)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p3, p4)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p4, p1)) { return(true); } } begin = _nodes[NodeCount - 1]; end = _nodes[0]; //4 уравнения if (Analysis.IsSegmentsIntersects(begin, end, p1, p2)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p2, p3)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p3, p4)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p4, p1)) { return(true); } //Принадлежность в полигне return(Analysis.PointInsidePolygon(_nodes, searchpoint)); }
internal override bool IsIntersects(Node searchpoint, double quad) { //1. Проверка на пересечение с границей Node p1 = new Node(searchpoint.X - quad, searchpoint.Y + quad); Node p2 = new Node(searchpoint.X + quad, searchpoint.Y + quad); Node p3 = new Node(searchpoint.X + quad, searchpoint.Y - quad); Node p4 = new Node(searchpoint.X - quad, searchpoint.Y - quad); Node begin; Node end; for (int i = 0; i < NodeCount - 1; i++) { begin = _nodes[i]; end = _nodes[i + 1]; if (Analysis.IsSegmentsIntersects(begin, end, p1, p2)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p2, p3)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p3, p4)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p4, p1)) { return(true); } } begin = _nodes[NodeCount - 1]; end = _nodes[0]; if (Analysis.IsSegmentsIntersects(begin, end, p1, p2)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p2, p3)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p3, p4)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p4, p1)) { return(true); } //2. Принадлежность точки полигону return(Analysis.PointInsidePolygon(_nodes, searchpoint)); //return false; }
internal override bool IsIntersects(Node searchpoint, double quad) { bool isBeginInside = (Begin.X >= searchpoint.X - quad) && (Begin.X <= searchpoint.X + quad) && (Begin.Y >= searchpoint.Y - quad) && (Begin.Y <= searchpoint.Y + quad); bool isEndInside = (End.X >= searchpoint.X - quad) && (End.X <= searchpoint.X + quad) && (End.Y >= searchpoint.Y - quad) && (End.Y <= searchpoint.Y + quad); if (isBeginInside || isEndInside) { return(true); } Node p1 = new Node(searchpoint.X - quad, searchpoint.Y + quad); Node p2 = new Node(searchpoint.X + quad, searchpoint.Y + quad); if (Analysis.IsSegmentsIntersects(Begin, End, p1, p2)) { return(true); } Node p3 = new Node(searchpoint.X + quad, searchpoint.Y - quad); if (Analysis.IsSegmentsIntersects(Begin, End, p2, p3)) { return(true); } Node p4 = new Node(searchpoint.X - quad, searchpoint.Y - quad); if (Analysis.IsSegmentsIntersects(Begin, End, p3, p4)) { return(true); } if (Analysis.IsSegmentsIntersects(Begin, End, p4, p1)) { return(true); } return(false); }
public override bool IsIntersects(Node searchpoint, double quad) { Node p1 = new Node(searchpoint.X - quad, searchpoint.Y + quad); Node p2 = new Node(searchpoint.X + quad, searchpoint.Y + quad); Node p3 = new Node(searchpoint.X + quad, searchpoint.Y - quad); Node p4 = new Node(searchpoint.X - quad, searchpoint.Y - quad); Node begin; Node end; for (int i = 0; i < NodeCount - 1; i++) { begin = _nodes[i]; end = _nodes[i + 1]; if (Analysis.IsSegmentsIntersects(begin, end, p1, p2)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p2, p3)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p3, p4)) { return(true); } if (Analysis.IsSegmentsIntersects(begin, end, p4, p1)) { return(true); } } return(false); }