# pyrotation
Interconversion of Euler angles, axis angles, quaternions, and rotation matrix.
Supports `numpy.ndarray` and `torch.Tensor`, and uses `plum-dispatch` to decorate functions of the same name.
In addition, it supports **arbitrary** shapes.
## Installation
```bash
pip install pyrotation
```
## conversion
we use `plum-dispatch` to decorate functions of the same name, so you can use `pyrotation.conversion` to convert between different representations.
We support `numpy.ndarray` and `torch.Tensor`, and the input can be of arbitrary shape.
| | quaternion | matrix | euler_angle | axis_angle |
| ---- | ---------- |------------------------| ----------- | ---------- |
| quaternion | - | `quaternion_from_matrix` | `quaternion_from_euler_angle` | `quaternion_from_axis_angle` |
| matrix | `matrix_from_quaternion` | - | `matrix_from_euler_angle` | `matrix_from_axis_angle` |
| euler_angle | `euler_angle_from_quaternion` | `euler_angle_from_matrix` | - | `euler_angle_from_axis_angle` |
| axis_angle | `axis_angle_from_quaternion` | `axis_angle_from_matrix` | `axis_angle_from_euler_angle` | - |
```python
import torch
from pyrotation.conversion import quaternion_from_matrix, euler_angle_from_matrix
# convert a 10x3x3 rotation matrix to a quaternion
R = torch.rand(10, 3, 3)
quat = quaternion_from_matrix(R)
euler_angle = euler_angle_from_matrix(R)
print(quat.shape) # torch.Size([10, 4])
print(euler_angle.shape) # torch.Size([10, 3])
```
We also support conversions between `so3` and `SO3`, `se3` and `SE3`. You can use `SO3_from_so3` and `SE3_from_se3` to convert `so3` and `se3` to `SO3` and `SE3`,
respectively. Similarly, you can use `so3_from_SO3` and `se3_from_SE3` to convert `SO3` and `SE3` to `so3` and `se3`, respectively.
Raw data
{
"_id": null,
"home_page": "",
"name": "pyrotation",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "fzhiheng <fzhazr@sjtu.edu.cn>",
"keywords": "SE3,SO3,axis-angle,euler,lie algebra,numpy,pytorch,quaternion,rotation,se3,so3",
"author": "",
"author_email": "fzhiheng <fzhazr@sjtu.edu.cn>",
"download_url": "https://files.pythonhosted.org/packages/ba/75/79ef8c8f0b962b340f457e021ab3f6696d7f93dabab6f73d74ae213aa124/pyrotation-0.0.2.tar.gz",
"platform": null,
"description": "# pyrotation\nInterconversion of Euler angles, axis angles, quaternions, and rotation matrix.\nSupports `numpy.ndarray` and `torch.Tensor`, and uses `plum-dispatch` to decorate functions of the same name.\nIn addition, it supports **arbitrary** shapes.\n\n## Installation\n```bash\npip install pyrotation\n```\n\n## conversion\nwe use `plum-dispatch` to decorate functions of the same name, so you can use `pyrotation.conversion` to convert between different representations.\nWe support `numpy.ndarray` and `torch.Tensor`, and the input can be of arbitrary shape.\n\n\n| | quaternion | matrix | euler_angle | axis_angle |\n| ---- | ---------- |------------------------| ----------- | ---------- |\n| quaternion | - | `quaternion_from_matrix` | `quaternion_from_euler_angle` | `quaternion_from_axis_angle` |\n| matrix | `matrix_from_quaternion` | - | `matrix_from_euler_angle` | `matrix_from_axis_angle` |\n| euler_angle | `euler_angle_from_quaternion` | `euler_angle_from_matrix` | - | `euler_angle_from_axis_angle` |\n| axis_angle | `axis_angle_from_quaternion` | `axis_angle_from_matrix` | `axis_angle_from_euler_angle` | - |\n \n```python\nimport torch\nfrom pyrotation.conversion import quaternion_from_matrix, euler_angle_from_matrix\n\n# convert a 10x3x3 rotation matrix to a quaternion\nR = torch.rand(10, 3, 3)\nquat = quaternion_from_matrix(R)\neuler_angle = euler_angle_from_matrix(R)\n\nprint(quat.shape) # torch.Size([10, 4])\nprint(euler_angle.shape) # torch.Size([10, 3])\n```\n\nWe also support conversions between `so3` and `SO3`, `se3` and `SE3`. You can use `SO3_from_so3` and `SE3_from_se3` to convert `so3` and `se3` to `SO3` and `SE3`, \nrespectively. Similarly, you can use `so3_from_SO3` and `se3_from_SE3` to convert `SO3` and `SE3` to `so3` and `se3`, respectively.\n",
"bugtrack_url": null,
"license": "",
"summary": "A package to handle rotation in 3D space with pytorch and numpy",
"version": "0.0.2",
"project_urls": {
"Homepage": "https://github.com/fzhiheng/pyrotation.git"
},
"split_keywords": [
"se3",
"so3",
"axis-angle",
"euler",
"lie algebra",
"numpy",
"pytorch",
"quaternion",
"rotation",
"se3",
"so3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d3efb71601d4c203aa87b43201bfb4fab68733ce242c62df4ce8acc5e9d3d811",
"md5": "6fcf291fc4a204df02f20297ba725375",
"sha256": "2da5706c9511d210a74076b2a7b6d7cdcf15c939323d29ca192bdfe712387935"
},
"downloads": -1,
"filename": "pyrotation-0.0.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "6fcf291fc4a204df02f20297ba725375",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 22292,
"upload_time": "2024-01-16T14:22:05",
"upload_time_iso_8601": "2024-01-16T14:22:05.924471Z",
"url": "https://files.pythonhosted.org/packages/d3/ef/b71601d4c203aa87b43201bfb4fab68733ce242c62df4ce8acc5e9d3d811/pyrotation-0.0.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ba7579ef8c8f0b962b340f457e021ab3f6696d7f93dabab6f73d74ae213aa124",
"md5": "27d6f925dea2331def0b57dfc02def8a",
"sha256": "270cab114d0f80bc621c6f1fba115a8be61ac5f4abf9f27c571c81f1f5f55c90"
},
"downloads": -1,
"filename": "pyrotation-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "27d6f925dea2331def0b57dfc02def8a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 22220,
"upload_time": "2024-01-16T14:22:08",
"upload_time_iso_8601": "2024-01-16T14:22:08.750347Z",
"url": "https://files.pythonhosted.org/packages/ba/75/79ef8c8f0b962b340f457e021ab3f6696d7f93dabab6f73d74ae213aa124/pyrotation-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-16 14:22:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fzhiheng",
"github_project": "pyrotation",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyrotation"
}