in theseus/geometry/se2.py [0:0]
def vee(matrix: torch.Tensor) -> torch.Tensor:
_check = matrix.ndim == 3 and matrix.shape[1:] == (3, 3)
_check &= torch.allclose(matrix[:, 0, 1], -matrix[:, 1, 0])
_check &= matrix[:, 0, 0].abs().max().item() < theseus.constants.EPS
_check &= matrix[:, 1, 1].abs().max().item() < theseus.constants.EPS
_check &= matrix[:, 2, 2].abs().max().item() < theseus.constants.EPS
if not _check:
raise ValueError("Invalid hat matrix for SE2.")
batch_size = matrix.shape[0]
tangent_vector = torch.zeros(batch_size, 3).to(
device=matrix.device, dtype=matrix.dtype
)
tangent_vector[:, 2] = matrix[:, 1, 0]
tangent_vector[:, :2] = matrix[:, :2, 2]
return tangent_vector