Returns true if polyline_a touches polyline_b.
503639
private static boolean polylineTouchesPolyline_(Polyline polyline_a,
			Polyline polyline_b, double tolerance,
			ProgressTracker progress_tracker) {
		// Quick rasterize test to see whether the the geometries are disjoint.
		if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance,
				false) == Relation.disjoint)
			return false;

		AttributeStreamOfDbl intersections = new AttributeStreamOfDbl(0);

		int dim = linearPathIntersectsLinearPathMaxDim_(polyline_a, polyline_b,
				tolerance, intersections);

		if (dim != 0)
			return false;

		MultiPoint intersection = new MultiPoint();

		for (int i = 0; i < intersections.size(); i += 2) {
			double x = intersections.read(i);
			double y = intersections.read(i + 1);
			intersection.add(x, y);
		}

		MultiPoint boundary_a_b = (MultiPoint) (polyline_a.getBoundary());
		MultiPoint boundary_b = (MultiPoint) (polyline_b.getBoundary());

		boundary_a_b.add(boundary_b, 0, boundary_b.getPointCount());

		return multiPointContainsMultiPointBrute_(boundary_a_b, intersection,
				tolerance);
	}
985379
private static boolean multiPointOverlapsMultiPoint_(
			MultiPoint multipoint_a, MultiPoint multipoint_b, double tolerance,
			ProgressTracker progress_tracker) {
		return multiPointCoverageMultiPoint_(multipoint_a, multipoint_b,
				tolerance, false, false, true, progress_tracker);
	}
143122
private static boolean polygonRelateMultiPoint_(Polygon polygon_a,
			MultiPoint multipoint_b, double tolerance, int relation,
			ProgressTracker progress_tracker) {
		switch (relation) {
		case Relation.disjoint:
			return polygonDisjointMultiPoint_(polygon_a, multipoint_b,
					tolerance, true, progress_tracker);

		case Relation.contains:
			return polygonContainsMultiPoint_(polygon_a, multipoint_b,
					tolerance, progress_tracker);

		case Relation.touches:
			return polygonTouchesMultiPoint_(polygon_a, multipoint_b,
					tolerance, progress_tracker);

		case Relation.crosses:
			return polygonCrossesMultiPoint_(polygon_a, multipoint_b,
					tolerance, progress_tracker);

		default:
			break; // warning fix
		}

		return false;
	}
1218003
private static boolean polylineDisjointPoint_(Polyline polyline_a,
			Point point_b, double tolerance, ProgressTracker progress_tracker) {
		// Quick rasterize test to see whether the the geometries are disjoint.
		if (tryRasterizedContainsOrDisjoint_(polyline_a, point_b, tolerance,
				false) == Relation.disjoint)
			return true;

		Point2D pt_b = point_b.getXY();
		return !linearPathIntersectsPoint_(polyline_a, pt_b, tolerance);
	}
165588
private static boolean pointEqualsPoint_(Point2D pt_a, Point2D pt_b,
			double tolerance, ProgressTracker progress_tracker) {
		if (Point2D.sqrDistance(pt_a, pt_b) <= tolerance * tolerance)
			return true;

		return false;
	}
139827
private static boolean polylineEqualsPolyline_(Polyline polyline_a,
			Polyline polyline_b, double tolerance,
			ProgressTracker progress_tracker) {
		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
		polyline_a.queryEnvelope2D(env_a);
		polyline_b.queryEnvelope2D(env_b);

		// Quick envelope rejection test for false equality.
		if (!envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker))
			return false;

		// Quick rasterize test to see whether the the geometries are disjoint.
		if (tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b, tolerance,
				false) == Relation.disjoint)
			return false;

		// Quick point equality check for true equality. This just checks if all
		// the points in each ring are the same (within a tolerance) and in the
		// same order
		if (multiPathExactlyEqualsMultiPath_(polyline_a, polyline_b, tolerance,
				progress_tracker))
			return true;

		return linearPathEqualsLinearPath_(polyline_a, polyline_b, tolerance, false);
	}
54631
public static boolean touches(Geometry geometry, Coordinate coordinate) {
		if (Geometry.MULTI_POLYGON.equals(geometry.getGeometryType())) {
			for (int i = 0; i < geometry.getGeometries().length; i++) {
				if (touches(geometry.getGeometries()[i], coordinate)) {
					return true;
				}
			}
			return false;
		} else if (Geometry.POLYGON.equals(geometry.getGeometryType())) {
			for (int i = 0; i < geometry.getGeometries().length; i++) {
				if (touchesLineString(geometry.getGeometries()[i], coordinate)) {
					return true;
				}
			}
			return false;
		} else if (Geometry.MULTI_LINE_STRING.equals(geometry.getGeometryType())) {
			for (int i = 0; i < geometry.getGeometries().length; i++) {
				if (touchesLineString(geometry.getGeometries()[i], coordinate)) {
					return true;
				}
			}
			return false;
		} else if (Geometry.LINEAR_RING.equals(geometry.getGeometryType())) {
			return touchesLineString(geometry, coordinate);
		} else if (Geometry.LINE_STRING.equals(geometry.getGeometryType())) {
			return touchesLineString(geometry, coordinate);
		} else if (Geometry.POINT.equals(geometry.getGeometryType())) {
			return distance(geometry.getCoordinates()[0], coordinate) < PARAM_DEFAULT_DELTA;
		}
		return false;
	}
1327554
static boolean polygonRelatePolygon_(Polygon polygon_a, Polygon polygon_b,
			double tolerance, String scl, ProgressTracker progress_tracker) {
		RelationalOperationsMatrix relOps = new RelationalOperationsMatrix();
		relOps.resetMatrix_();
		relOps.setPredicates_(scl);
		relOps.setAreaAreaPredicates_();

		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
		polygon_a.queryEnvelope2D(env_a);
		polygon_b.queryEnvelope2D(env_b);

		boolean bRelationKnown = false;
		boolean b_disjoint = RelationalOperations.envelopeDisjointEnvelope_(
				env_a, env_b, tolerance, progress_tracker);

		if (b_disjoint) {
			relOps.areaAreaDisjointPredicates_(polygon_a, polygon_b);
			bRelationKnown = true;
		}

		if (!bRelationKnown) {
			// Quick rasterize test to see whether the the geometries are
			// disjoint, or if one is contained in the other.
			int relation = RelationalOperations
					.tryRasterizedContainsOrDisjoint_(polygon_a, polygon_b,
							tolerance, false);

			if (relation == RelationalOperations.Relation.disjoint) {
				relOps.areaAreaDisjointPredicates_(polygon_a, polygon_b);
				bRelationKnown = true;
			} else if (relation == RelationalOperations.Relation.contains) {
				relOps.areaAreaContainsPredicates_(polygon_b);
				bRelationKnown = true;
			} else if (relation == RelationalOperations.Relation.within) {
				relOps.areaAreaWithinPredicates_(polygon_a);
				bRelationKnown = true;
			}
		}

		if (!bRelationKnown) {
			EditShape edit_shape = new EditShape();
			int geom_a = edit_shape.addGeometry(polygon_a);
			int geom_b = edit_shape.addGeometry(polygon_b);
			relOps.setEditShapeCrackAndCluster_(edit_shape, tolerance,
					progress_tracker);
			relOps.computeMatrixTopoGraphHalfEdges_(geom_a, geom_b);
			relOps.m_topo_graph.removeShape();
		}

		boolean bRelation = relationCompare_(relOps.m_matrix, relOps.m_scl);
		return bRelation;
	}
236960
static boolean polylineRelatePolyline_(Polyline polyline_a,
			Polyline polyline_b, double tolerance, String scl,
			ProgressTracker progress_tracker) {
		RelationalOperationsMatrix relOps = new RelationalOperationsMatrix();
		relOps.resetMatrix_();
		relOps.setPredicates_(scl);
		relOps.setLineLinePredicates_();

		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
		polyline_a.queryEnvelope2D(env_a);
		polyline_b.queryEnvelope2D(env_b);

		boolean bRelationKnown = false;
		boolean b_disjoint = RelationalOperations.envelopeDisjointEnvelope_(
				env_a, env_b, tolerance, progress_tracker);

		if (b_disjoint) {
			relOps.lineLineDisjointPredicates_(polyline_a, polyline_b);
			bRelationKnown = true;
		}

		if (!bRelationKnown) {
			// Quick rasterize test to see whether the the geometries are
			// disjoint, or if one is contained in the other.
			int relation = RelationalOperations
					.tryRasterizedContainsOrDisjoint_(polyline_a, polyline_b,
							tolerance, false);

			if (relation == RelationalOperations.Relation.disjoint) {
				relOps.lineLineDisjointPredicates_(polyline_a, polyline_b);
				bRelationKnown = true;
			}
		}

		if (!bRelationKnown) {
			EditShape edit_shape = new EditShape();
			int geom_a = edit_shape.addGeometry(polyline_a);
			int geom_b = edit_shape.addGeometry(polyline_b);
			relOps.setEditShapeCrackAndCluster_(edit_shape, tolerance,
					progress_tracker);
			relOps.m_cluster_index_a = relOps.m_topo_graph
					.createUserIndexForClusters();
			relOps.m_cluster_index_b = relOps.m_topo_graph
					.createUserIndexForClusters();
			markClusterEndPoints_(geom_a, relOps.m_topo_graph,
					relOps.m_cluster_index_a);
			markClusterEndPoints_(geom_b, relOps.m_topo_graph,
					relOps.m_cluster_index_b);
			relOps.computeMatrixTopoGraphHalfEdges_(geom_a, geom_b);
			relOps.m_topo_graph
					.deleteUserIndexForClusters(relOps.m_cluster_index_a);
			relOps.m_topo_graph
					.deleteUserIndexForClusters(relOps.m_cluster_index_b);
			relOps.m_topo_graph.removeShape();
		}

		boolean bRelation = relationCompare_(relOps.m_matrix, relOps.m_scl);
		return bRelation;
	}
207574
def lines_touch_2D(ab, cd):
    '''
    
    '''
    return lines_colinear(ab, cd) | np.isfinite(line_intersection_2D(ab, cd)[0])
381902
def is_adjacent(self, another_edge):
        
        return (
            self.L == another_edge.L
            or self.L == another_edge.R
            or self.R == another_edge.L
            or self.R == another_edge.R
        )
91935
static boolean polygonRelatePoint_(Polygon polygon_a, Point point_b,
			double tolerance, String scl, ProgressTracker progress_tracker) {
        RelationalOperationsMatrix relOps = new RelationalOperationsMatrix();
        relOps.resetMatrix_();
        relOps.setPredicates_(scl);
        relOps.setAreaPointPredicates_();

        Envelope2D env_a = new Envelope2D();
        polygon_a.queryEnvelope2D(env_a);
        Point2D pt_b = point_b.getXY();

        boolean bRelationKnown = false;
        boolean b_disjoint = RelationalOperations.pointDisjointEnvelope_(pt_b, env_a, tolerance, progress_tracker);

        if (b_disjoint)
        {
            relOps.areaPointDisjointPredicates_(polygon_a);
            bRelationKnown = true;
        }

        if (!bRelationKnown)
        {
            PolygonUtils.PiPResult res = PolygonUtils.isPointInPolygon2D(polygon_a, pt_b, tolerance); // uses accelerator

            if (res == PolygonUtils.PiPResult.PiPInside)
            {// polygon must have area
                relOps.m_matrix[MatrixPredicate.InteriorInterior] = 0;
                relOps.m_matrix[MatrixPredicate.InteriorExterior] = 2;
                relOps.m_matrix[MatrixPredicate.BoundaryInterior] = -1;
                relOps.m_matrix[MatrixPredicate.BoundaryExterior] = 1;
                relOps.m_matrix[MatrixPredicate.ExteriorInterior] = -1;
            }
            else if (res == PolygonUtils.PiPResult.PiPBoundary)
            {
                relOps.m_matrix[MatrixPredicate.ExteriorInterior] = -1;

                double area = polygon_a.calculateArea2D();

                if (area != 0)
                {
                    relOps.m_matrix[MatrixPredicate.InteriorInterior] = -1;
                    relOps.m_matrix[MatrixPredicate.BoundaryInterior] = 0;
                    relOps.m_matrix[MatrixPredicate.InteriorExterior] = 2;
                    relOps.m_matrix[MatrixPredicate.BoundaryExterior] = 1;
                }
                else
                {
                    relOps.m_matrix[MatrixPredicate.InteriorInterior] = 0;
                    relOps.m_matrix[MatrixPredicate.BoundaryInterior] = -1;
                    relOps.m_matrix[MatrixPredicate.BoundaryExterior] = -1;

                    Envelope2D env = new Envelope2D();
                    polygon_a.queryEnvelope2D(env);
                    relOps.m_matrix[MatrixPredicate.InteriorExterior] = (env.getHeight() == 0.0 && env.getWidth() == 0.0 ? -1 : 1);
                }
            }
            else
            {
                relOps.areaPointDisjointPredicates_(polygon_a);
            }
        }

        boolean bRelation = relationCompare_(relOps.m_matrix, scl);
        return bRelation;
	}
410728
private boolean isCrossed(Point2d beg1, Point2d end1, Point2d beg2, Point2d end2) {
        return Line2D.linesIntersect(beg1.x, beg1.y, end1.x, end1.y, beg2.x, beg2.y, end2.x, end2.y);
    }
401646
private static boolean checkCollide(Area area, Collidable other)
    {
        final List<Rectangle> others = other.getCollisionBounds();
        final int size = others.size();
        for (int i = 0; i < size; i++)
        {
            final Area current = others.get(i);
            if (area.intersects(current))
            {
                return true;
            }
        }
        return false;
    }
1306972
private static boolean polygonContainsPolygon_(Polygon polygon_a,
			Polygon polygon_b, double tolerance,
			ProgressTracker progress_tracker) {
		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
		polygon_a.queryEnvelope2D(env_a);
		polygon_b.queryEnvelope2D(env_b);

		// Quick envelope rejection test for false equality.
		if (!envelopeInfContainsEnvelope_(env_a, env_b, tolerance))
			return false;

		// Quick rasterize test to see whether the the geometries are disjoint,
		// or if one is contained in the other.
		int relation = tryRasterizedContainsOrDisjoint_(polygon_a, polygon_b,
				tolerance, false);

		if (relation == Relation.disjoint || relation == Relation.within)
			return false;

		if (relation == Relation.contains)
			return true;

		return polygonContainsPolygonImpl_(polygon_a, polygon_b, tolerance,
				progress_tracker);
	}
946640
private static boolean polygonDisjointPoint_(Polygon polygon_a,
			Point point_b, double tolerance, ProgressTracker progress_tracker) {
		PolygonUtils.PiPResult result = PolygonUtils.isPointInPolygon2D(
				polygon_a, point_b, tolerance);

		if (result == PolygonUtils.PiPResult.PiPOutside)
			return true;

		return false;
	}
168663
def has_intersection(self, other):
        
        return bool(lib.SDL_HasIntersection(self._ptr, other._ptr))