-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
90 changed files
with
4,945 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
repos: | ||
- hooks: | ||
- id: "check-toml" | ||
- id: "check-yaml" | ||
repo: "https://github.com/pre-commit/pre-commit-hooks" | ||
rev: "v4.5.0" | ||
- hooks: | ||
- args: | ||
- "--fix" | ||
id: "ruff" | ||
- id: "ruff-format" | ||
repo: "https://github.com/astral-sh/ruff-pre-commit" | ||
rev: "v0.3.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# beignet.ops | ||
|
||
## Geometry | ||
|
||
### Transformations | ||
|
||
#### Rotations | ||
|
||
#### Translations | ||
|
||
## Interpolation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,33 @@ requires = [ | |
|
||
[project] | ||
authors = [{ email = "[email protected]", name = "Allen Goodman" }] | ||
dependencies = ["torch"] | ||
dynamic = ["version"] | ||
license = { file = "LICENSE" } | ||
name = "beignet" | ||
readme = "README.md" | ||
requires-python = ">=3.10" | ||
|
||
[tool.ruff.format] | ||
docstring-code-format = true | ||
[project.optional-dependencies] | ||
test = [ | ||
"hypothesis", | ||
"pytest", | ||
"scipy", | ||
] | ||
|
||
[tool.ruff] | ||
select = [ | ||
"B", # FLAKE8-BUGBEAR | ||
"E", # PYCODESTYLE ERRORS | ||
"F", # PYFLAKES | ||
"I", # ISORT | ||
"W", # PYCODESTYLE WARNINGS | ||
] | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"__init__.py" = [ | ||
"F401", # MODULE IMPORTED BUT UNUSED | ||
] | ||
|
||
[tool.setuptools_scm] | ||
local_scheme = "no-local-version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
from ._geometry import ( | ||
apply_euler_angle, | ||
apply_quaternion, | ||
apply_rotation_matrix, | ||
apply_rotation_vector, | ||
compose_euler_angle, | ||
compose_quaternion, | ||
compose_rotation_matrix, | ||
compose_rotation_vector, | ||
euler_angle_identity, | ||
euler_angle_magnitude, | ||
euler_angle_mean, | ||
euler_angle_to_quaternion, | ||
euler_angle_to_rotation_matrix, | ||
euler_angle_to_rotation_vector, | ||
invert_euler_angle, | ||
invert_quaternion, | ||
invert_rotation_matrix, | ||
invert_rotation_vector, | ||
quaternion_identity, | ||
quaternion_magnitude, | ||
quaternion_mean, | ||
quaternion_slerp, | ||
quaternion_to_euler_angle, | ||
quaternion_to_rotation_matrix, | ||
quaternion_to_rotation_vector, | ||
random_euler_angle, | ||
random_quaternion, | ||
random_rotation_matrix, | ||
random_rotation_vector, | ||
rotation_matrix_identity, | ||
rotation_matrix_magnitude, | ||
rotation_matrix_mean, | ||
rotation_matrix_to_euler_angle, | ||
rotation_matrix_to_quaternion, | ||
rotation_matrix_to_rotation_vector, | ||
rotation_vector_identity, | ||
rotation_vector_magnitude, | ||
rotation_vector_mean, | ||
rotation_vector_to_euler_angle, | ||
rotation_vector_to_quaternion, | ||
rotation_vector_to_rotation_matrix, | ||
translation_identity, | ||
) | ||
|
||
__all__ = [ | ||
"apply_euler_angle", | ||
"apply_quaternion", | ||
"apply_rotation_matrix", | ||
"apply_rotation_vector", | ||
"compose_euler_angle", | ||
"compose_quaternion", | ||
"compose_rotation_matrix", | ||
"compose_rotation_vector", | ||
"euler_angle_identity", | ||
"euler_angle_magnitude", | ||
"euler_angle_mean", | ||
"euler_angle_to_quaternion", | ||
"euler_angle_to_rotation_matrix", | ||
"euler_angle_to_rotation_vector", | ||
"invert_euler_angle", | ||
"invert_quaternion", | ||
"invert_rotation_matrix", | ||
"invert_rotation_vector", | ||
"quaternion_identity", | ||
"quaternion_magnitude", | ||
"quaternion_mean", | ||
"quaternion_to_euler_angle", | ||
"quaternion_to_rotation_matrix", | ||
"quaternion_to_rotation_vector", | ||
"random_euler_angle", | ||
"random_quaternion", | ||
"random_rotation_matrix", | ||
"random_rotation_vector", | ||
"rotation_matrix_identity", | ||
"rotation_matrix_magnitude", | ||
"rotation_matrix_mean", | ||
"rotation_matrix_to_euler_angle", | ||
"rotation_matrix_to_quaternion", | ||
"rotation_matrix_to_rotation_vector", | ||
"rotation_vector_identity", | ||
"rotation_vector_magnitude", | ||
"rotation_vector_mean", | ||
"rotation_vector_to_euler_angle", | ||
"rotation_vector_to_quaternion", | ||
"rotation_vector_to_rotation_matrix", | ||
"quaternion_slerp", | ||
"translation_identity", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from ._transformations import ( | ||
apply_euler_angle, | ||
apply_quaternion, | ||
apply_rotation_matrix, | ||
apply_rotation_vector, | ||
compose_euler_angle, | ||
compose_quaternion, | ||
compose_rotation_matrix, | ||
compose_rotation_vector, | ||
euler_angle_identity, | ||
euler_angle_magnitude, | ||
euler_angle_mean, | ||
euler_angle_to_quaternion, | ||
euler_angle_to_rotation_matrix, | ||
euler_angle_to_rotation_vector, | ||
invert_euler_angle, | ||
invert_quaternion, | ||
invert_rotation_matrix, | ||
invert_rotation_vector, | ||
quaternion_identity, | ||
quaternion_magnitude, | ||
quaternion_mean, | ||
quaternion_slerp, | ||
quaternion_to_euler_angle, | ||
quaternion_to_rotation_matrix, | ||
quaternion_to_rotation_vector, | ||
random_euler_angle, | ||
random_quaternion, | ||
random_rotation_matrix, | ||
random_rotation_vector, | ||
rotation_matrix_identity, | ||
rotation_matrix_magnitude, | ||
rotation_matrix_mean, | ||
rotation_matrix_to_euler_angle, | ||
rotation_matrix_to_quaternion, | ||
rotation_matrix_to_rotation_vector, | ||
rotation_vector_identity, | ||
rotation_vector_magnitude, | ||
rotation_vector_mean, | ||
rotation_vector_to_euler_angle, | ||
rotation_vector_to_quaternion, | ||
rotation_vector_to_rotation_matrix, | ||
translation_identity, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from ._apply_euler_angle import apply_euler_angle | ||
from ._apply_quaternion import ( | ||
apply_quaternion, | ||
) | ||
from ._apply_rotation_matrix import apply_rotation_matrix | ||
from ._apply_rotation_vector import apply_rotation_vector | ||
from ._compose_euler_angle import compose_euler_angle | ||
from ._compose_quaternion import compose_quaternion | ||
from ._compose_rotation_matrix import compose_rotation_matrix | ||
from ._compose_rotation_vector import compose_rotation_vector | ||
from ._euler_angle_identity import euler_angle_identity | ||
from ._euler_angle_magnitude import euler_angle_magnitude | ||
from ._euler_angle_mean import euler_angle_mean | ||
from ._euler_angle_to_quaternion import ( | ||
euler_angle_to_quaternion, | ||
) | ||
from ._euler_angle_to_rotation_matrix import euler_angle_to_rotation_matrix | ||
from ._euler_angle_to_rotation_vector import euler_angle_to_rotation_vector | ||
from ._invert_euler_angle import invert_euler_angle | ||
from ._invert_quaternion import invert_quaternion | ||
from ._invert_rotation_matrix import invert_rotation_matrix | ||
from ._invert_rotation_vector import invert_rotation_vector | ||
from ._quaternion_identity import quaternion_identity | ||
from ._quaternion_magnitude import quaternion_magnitude | ||
from ._quaternion_mean import quaternion_mean | ||
from ._quaternion_slerp import quaternion_slerp | ||
from ._quaternion_to_euler_angle import ( | ||
quaternion_to_euler_angle, | ||
) | ||
from ._quaternion_to_rotation_matrix import ( | ||
quaternion_to_rotation_matrix, | ||
) | ||
from ._quaternion_to_rotation_vector import ( | ||
quaternion_to_rotation_vector, | ||
) | ||
from ._random_euler_angle import random_euler_angle | ||
from ._random_quaternion import random_quaternion | ||
from ._random_rotation_matrix import random_rotation_matrix | ||
from ._random_rotation_vector import random_rotation_vector | ||
from ._rotation_matrix_identity import rotation_matrix_identity | ||
from ._rotation_matrix_magnitude import rotation_matrix_magnitude | ||
from ._rotation_matrix_mean import rotation_matrix_mean | ||
from ._rotation_matrix_to_euler_angle import rotation_matrix_to_euler_angle | ||
from ._rotation_matrix_to_quaternion import ( | ||
rotation_matrix_to_quaternion, | ||
) | ||
from ._rotation_matrix_to_rotation_vector import ( | ||
rotation_matrix_to_rotation_vector, | ||
) | ||
from ._rotation_vector_identity import rotation_vector_identity | ||
from ._rotation_vector_magnitude import rotation_vector_magnitude | ||
from ._rotation_vector_mean import rotation_vector_mean | ||
from ._rotation_vector_to_euler_angle import rotation_vector_to_euler_angle | ||
from ._rotation_vector_to_quaternion import ( | ||
rotation_vector_to_quaternion, | ||
) | ||
from ._rotation_vector_to_rotation_matrix import ( | ||
rotation_vector_to_rotation_matrix, | ||
) | ||
from ._translation_identity import translation_identity |
63 changes: 63 additions & 0 deletions
63
src/beignet/ops/_geometry/_transformations/_apply_euler_angle.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
from torch import Tensor | ||
|
||
from ._apply_rotation_matrix import apply_rotation_matrix | ||
from ._euler_angle_to_rotation_matrix import euler_angle_to_rotation_matrix | ||
|
||
|
||
def apply_euler_angle( | ||
input: Tensor, | ||
rotation: Tensor, | ||
axes: str, | ||
degrees: bool = False, | ||
inverse: bool = False, | ||
) -> Tensor: | ||
r""" | ||
Rotates vectors in three-dimensional space using Euler angles. | ||
Note | ||
---- | ||
This function interprets the rotation of the original frame to the final | ||
frame as either a projection, where it maps the components of vectors from | ||
the final frame to the original frame, or as a physical rotation, | ||
integrating the vectors into the original frame during the rotation | ||
process. Consequently, the vector components are maintained in the original | ||
frame’s perspective both before and after the rotation. | ||
Parameters | ||
---------- | ||
input : Tensor | ||
Vectors in three-dimensional space with the shape $(\ldots \times 3)$. | ||
Euler angles and vectors must conform to PyTorch broadcasting rules. | ||
rotation : Tensor | ||
Euler angles with the shape $(\ldots \times 3)$, specifying the | ||
rotation in three-dimensional space. | ||
axes : str | ||
Specifies the sequence of axes for the rotations, using one to three | ||
characters from the set ${X, Y, Z}$ for intrinsic rotations, or | ||
${x, y, z}$ for extrinsic rotations. Mixing extrinsic and intrinsic | ||
rotations raises a `ValueError`. | ||
degrees : bool, optional | ||
Indicates whether the Euler angles are provided in degrees. If `False`, | ||
angles are assumed to be in radians. Default, `False`. | ||
inverse : bool, optional | ||
If `True`, applies the inverse rotation using the Euler angles to the | ||
input vectors. Default, `False`. | ||
Returns | ||
------- | ||
output : Tensor | ||
A tensor of the same shape as `input`, containing the rotated vectors. | ||
""" | ||
return apply_rotation_matrix( | ||
input, | ||
euler_angle_to_rotation_matrix( | ||
rotation, | ||
axes, | ||
degrees, | ||
), | ||
inverse, | ||
) |
Oops, something went wrong.