Shortcuts

pypose.from_matrix

pypose.from_matrix(mat, ltype, check=True, rtol=1e-05, atol=1e-05)[source]

Convert batched rotation or transformation matrices to LieTensor.

Parameters
  • mat (Tensor) – the matrix to convert.

  • ltype (ltype) – specify the LieTensor type, chosen from pypose.SO3_type, pypose.SE3_type, pypose.Sim3_type, or pypose.RxSO3_type. See more details in LieTensor()

  • check (bool, optional) – flag to check if the input is valid rotation matrices (orthogonal and with a determinant of one). Set to False if less computation is needed. Default: True.

  • rtol (float, optional) – relative tolerance when check is enabled. Default: 1e-05

  • atol (float, optional) – absolute tolerance when check is enabled. Default: 1e-05

Warning

Numerically, a transformation matrix is considered legal if:

\[|{\rm det}(\mathbf{R}) - 1| \leq \texttt{atol} + \texttt{rtol}\times 1\\ |\mathbf{RR}^{T} - \mathbf{I}| \leq \texttt{atol} + \texttt{rtol}\times \mathbf{I} \]

where \(|\cdot |\) is element-wise absolute function. When check is set to True, illegal input will raise a ValueError. Otherwise, no data validation is performed. Illegal input will output an irrelevant result, which likely contains nan.

Returns

the converted LieTensor.

Return type

LieTensor

Examples

  • pypose.SO3_type

>>> pp.from_matrix(torch.tensor([[0., -1., 0.],
...                              [1.,  0., 0.],
...                              [0.,  0., 1.]]), ltype=pp.SO3_type)
SO3Type LieTensor:
tensor([0.0000, 0.0000, 0.7071, 0.7071])
  • pypose.SE3_type

>>> pp.from_matrix(torch.tensor([[0., -1., 0., 0.1],
...                              [1.,  0., 0., 0.2],
...                              [0.,  0., 1., 0.3],
...                              [0.,  0., 0.,  1.]]), ltype=pp.SE3_type)
SE3Type LieTensor:
tensor([0.1000, 0.2000, 0.3000, 0.0000, 0.0000, 0.7071, 0.7071])
  • pypose.Sim3_type

>>> pp.from_matrix(torch.tensor([[ 0.,-0.5,  0., 0.1],
...                              [0.5,  0.,  0., 0.2],
...                              [ 0.,  0., 0.5, 0.3],
...                              [ 0.,  0.,  0.,  1.]]), ltype=pp.Sim3_type)
Sim3Type LieTensor:
tensor([0.1000, 0.2000, 0.3000, 0.0000, 0.0000, 0.7071, 0.7071, 0.5000])
  • pypose.RxSO3_type

>>> pp.from_matrix(torch.tensor([[0., -0.5, 0.],
...                              [0.5, 0.,  0.],
...                              [0.,  0., 0.5]]), ltype=pp.RxSO3_type)
RxSO3Type LieTensor:
tensor([0.0000, 0.0000, 0.7071, 0.7071, 0.5000])

Docs

Access documentation for PyPose

View Docs

Tutorials

Get started with tutorials and examples

View Tutorials

Get Started

Find resources and how to start using pypose

View Resources