diff --git a/Raytrace/SideScan.py b/Raytrace/SideScan.py index 54d1df4..3896246 100644 --- a/Raytrace/SideScan.py +++ b/Raytrace/SideScan.py @@ -23,6 +23,18 @@ def __init__(self, distances:np.ndarray, rays:list[Ray]): self.finite = np.isfinite(self.distances) self.intersection_count = np.count_nonzero(self.finite) np.seterr(**old_error_state) + def combine_min(self, other:Self) -> Self: + if len(self.distances) != len(other.distances): + raise ValueError("Cannot combine two readings of different sizes") + if np.any(self.origins != other.origins) or np.any(self.directions != other.directions): + pass # TODO: add warning + new_distances = self.distances.copy() + other_smaller = new_distances > other.distances + new_distances[other_smaller] = other.distances[other_smaller] + + # HACK: new rays should be generated based on which distance was closer + new_rays = [Ray(i, j) for i, j in zip(self.directions, self.origins)] + return type(self)(new_distances, new_rays) def print_summary(self) -> None: print('Intersections:', self.intersection_count , '/', len(self.distances))