diff --git a/aloscene/camera_calib.py b/aloscene/camera_calib.py index 51efb776..f131e725 100644 --- a/aloscene/camera_calib.py +++ b/aloscene/camera_calib.py @@ -183,8 +183,8 @@ class CameraExtrinsic(AugmentedTensor): """ @staticmethod - def __new__(cls, x, *args, **kwargs): - tensor = super().__new__(cls, x, *args, **kwargs) + def __new__(cls, x, *args, names=(None, None), **kwargs): + tensor = super().__new__(cls, x, *args, names=names, **kwargs) return tensor def translation_with(self, tgt_pos): @@ -204,6 +204,21 @@ def translation_with(self, tgt_pos): translation = Ttgt2self[..., :3, -1] return translation + def distance_with(self, tgt_pos): + """ Compute the distance with an other pos + + Parameters + ---------- + tgt_pos: aloscene.Pose + Target pose to compute the distance with + + Returns + ------- + n_pos: torch.tensor + Translation tensor of shape (..., 3) + """ + return torch.linalg.norm(self.translation_with(tgt_pos), dim=-1) + def __init__(self, x, *args, **kwargs): assert x.shape[-2] == 4 and x.shape[-1] == 4 super().__init__(x)