From 823c60002e88ae388c8398ad95bb95dbb435968a Mon Sep 17 00:00:00 2001 From: Tobias Fischer <36965290+tobiasfshr@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:27:36 +0100 Subject: [PATCH] Add 'within' function to SceneBox (#2991) Co-authored-by: Matias Turkulainen <30566358+maturk@users.noreply.github.com> --- nerfstudio/data/scene_box.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nerfstudio/data/scene_box.py b/nerfstudio/data/scene_box.py index bf36702045..4abf60ea00 100644 --- a/nerfstudio/data/scene_box.py +++ b/nerfstudio/data/scene_box.py @@ -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]