Add 'within' function to SceneBox (#2991)

Co-authored-by: Matias Turkulainen <30566358+maturk@users.noreply.github.com>
This commit is contained in:
Tobias FischerandMatias Turkulainen authored and GitHub committed 2024-03-11 10:27:36 -07:00
1 parent 9960de0e84
commit 946151ac45
1 file changed
+4
+4
View File
@@ -34,6 +34,10 @@ class SceneBox:
aabb[0] is the minimum (x,y,z) point.
aabb[1] is the maximum (x,y,z) point."""
def within(self, pts: Float[Tensor, "n 3"]):
"""Returns a boolean mask indicating whether each point is within the box."""
return torch.all(pts > self.aabb[0], dim=-1) & torch.all(pts < self.aabb[1], dim=-1)
def get_diagonal_length(self):
"""Returns the longest diagonal length."""
diff = self.aabb[1] - self.aabb[0]