# kornia.geometry.linalg¶

kornia.geometry.linalg.relative_transformation(trans_01, trans_02)[source]

Function that computes the relative homogeneous transformation from a reference transformation $$T_1^{0} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}$$ to destination $$T_2^{0} = \begin{bmatrix} R_2 & t_2 \\ \mathbf{0} & 1 \end{bmatrix}$$.

The relative transformation is computed as follows:

$T_1^{2} = (T_0^{1})^{-1} \cdot T_0^{2}$
Parameters
• trans_01 (Tensor) – reference transformation tensor of shape $$(N, 4, 4)$$ or $$(4, 4)$$.

• trans_02 (Tensor) – destination transformation tensor of shape $$(N, 4, 4)$$ or $$(4, 4)$$.

Return type

Tensor

Returns

the relative transformation between the transformations with shape $$(N, 4, 4)$$ or $$(4, 4)$$.

Example::
>>> trans_01 = torch.eye(4)  # 4x4
>>> trans_02 = torch.eye(4)  # 4x4
>>> trans_12 = relative_transformation(trans_01, trans_02)  # 4x4
kornia.geometry.linalg.compose_transformations(trans_01, trans_12)[source]

Function that composes two homogeneous transformations.

$\begin{split}T_0^{2} = \begin{bmatrix} R_0^1 R_1^{2} & R_0^{1} t_1^{2} + t_0^{1} \\ \mathbf{0} & 1\end{bmatrix}\end{split}$
Parameters
• trans_01 (Tensor) – tensor with the homogeneous transformation from a reference frame 1 respect to a frame 0. The tensor has must have a shape of $$(N, 4, 4)$$ or $$(4, 4)$$.

• trans_12 (Tensor) – tensor with the homogeneous transformation from a reference frame 2 respect to a frame 1. The tensor has must have a shape of $$(N, 4, 4)$$ or $$(4, 4)$$.

Return type

Tensor

Returns

the transformation between the two frames with shape $$(N, 4, 4)$$ or $$(4, 4)$$.

Example::
>>> trans_01 = torch.eye(4)  # 4x4
>>> trans_12 = torch.eye(4)  # 4x4
>>> trans_02 = compose_transformations(trans_01, trans_12)  # 4x4
kornia.geometry.linalg.inverse_transformation(trans_12)[source]

Function that inverts a 4x4 homogeneous transformation $$T_1^{2} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}$$

The inverse transformation is computed as follows:

$\begin{split}T_2^{1} = (T_1^{2})^{-1} = \begin{bmatrix} R_1^T & -R_1^T t_1 \\ \mathbf{0} & 1\end{bmatrix}\end{split}$
Parameters

trans_12 – transformation tensor of shape $$(N, 4, 4)$$ or $$(4, 4)$$.

Returns

tensor with inverted transformations with shape $$(N, 4, 4)$$ or $$(4, 4)$$.

Example

>>> trans_12 = torch.rand(1, 4, 4)  # Nx4x4
>>> trans_21 = inverse_transformation(trans_12)  # Nx4x4
kornia.geometry.linalg.transform_points(trans_01, points_1)[source]

Function that applies transformations to a set of points.

Parameters
• trans_01 (torch.Tensor) – tensor for transformations of shape $$(B, D+1, D+1)$$.

• points_1 (torch.Tensor) – tensor of points of shape $$(B, N, D)$$.

Returns

tensor of N-dimensional points.

Return type

torch.Tensor

Shape:
• Output: $$(B, N, D)$$

Examples

>>> points_1 = torch.rand(2, 4, 3)  # BxNx3
>>> trans_01 = torch.eye(4).view(1, 4, 4)  # Bx4x4
>>> points_0 = transform_points(trans_01, points_1)  # BxNx3