Skip to content

Commit

Permalink
Added combine_min function
Browse files Browse the repository at this point in the history
Added function to take the min of two raw readings
  • Loading branch information
JoeBell committed Mar 3, 2025
1 parent 11ff274 commit b1516ee
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Raytrace/SideScan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b1516ee

Please sign in to comment.