in metropolis/utils/data_classes.py [0:0]
def corners(self, lwh_factor: float = 1.0) -> np.ndarray:
"""Returns the bounding box corners.
Args:
lwh_factor: Multiply l, w, h by a factor to scale the box.
Returns:
First four corners are the ones facing forward. The last four are the
ones facing backwards.
"""
l, w, h = self.lwh * lwh_factor
# 3D bounding box corners. (Convention: x points right, y to the front, z up.)
y_corners = l / 2 * np.array([1, 1, 1, 1, -1, -1, -1, -1])
x_corners = w / 2 * np.array([-1, 1, 1, -1, -1, 1, 1, -1])
z_corners = h / 2 * np.array([1, 1, -1, -1, 1, 1, -1, -1])
corners = np.vstack((x_corners, y_corners, z_corners))
# Rotate
corners = np.dot(self.orientation.rotation_matrix, corners)
# Translate
x, y, z = self.center
corners[0, :] = corners[0, :] + x
corners[1, :] = corners[1, :] + y
corners[2, :] = corners[2, :] + z
return corners