def is_valid(self): for i in range(len(self.edges) - 2): for j in range(i + 2, len(self.edges) - (i == 0)): edge_i = self.edges[i] edge_j = self.edges[j] if GeoTools.doIntersect(edge_i[0], edge_i[1], edge_j[0], edge_j[1]): return False return True
def is_intersected(self, line, config): if config is not None: edges = self.edges[config] else: edges = self.edges for edge in edges: if GeoTools.doIntersect(edge[0], edge[1], line[0], line[1]): return True return False
def is_intersected(self, line, config="worst"): """Return True if self is intersected by a line. Args: line (list of Point): line to consider for intersection with self. config (str): rectangle configuration to check line intersection for, defaults to "worst", but other options are "best" or "full". """ for edge in self.edges[config]: if GeoTools.doIntersect(edge[0], edge[1], line[0], line[1]): return True return False