Add AABox convenience functions
@@ -34,7 +34,20 @@ class AABox(Geometry):
def upper(self, upper):
return math.to_float(math.as_tensor(upper))
- @property
+ def get_lower(self, axis):
+ return self._get(self.lower, axis)
+
+ def get_upper(self, axis):
+ return self._get(self.upper, axis)
+
+ @staticmethod
+ def _get(vector, axis):
+ if math.ndims(vector) == 0:
+ return vector
+ else:
+ return vector[...,axis]
+
+ @struct.derived()
def size(self):
return self.upper - self.lower
@@ -65,6 +78,15 @@ class AABox(Geometry):
else:
raise NotImplementedError()
+ def without_axis(self, axis):
+ lower = []
+ upper = []
+ for ax in range(self.rank):
+ if ax != axis:
+ lower.append(self.get_lower(axis))
+ upper.append(self.get_upper(axis))
+ return self.copied_with(lower=lower, upper=upper)
+
def __repr__(self):
try:
return '%s at (%s)' % ('x'.join([str(x) for x in self.size]), ','.join([str(x) for x in self.lower]))
