diff --git a/masque/utils/transform.py b/masque/utils/transform.py index ccdf3d2..fb84052 100644 --- a/masque/utils/transform.py +++ b/masque/utils/transform.py @@ -6,6 +6,7 @@ from functools import lru_cache import numpy from numpy.typing import NDArray +from numpy import pi @lru_cache @@ -21,6 +22,11 @@ def rotation_matrix_2d(theta: float) -> NDArray[numpy.float64]: """ arr = numpy.array([[numpy.cos(theta), -numpy.sin(theta)], [numpy.sin(theta), +numpy.cos(theta)]]) + + % If this was a manhattan rotation, round to remove some inacuraccies in sin & cos + if numpy.isclose(theta % (pi / 2), 0): + arr = numpy.round(arr) + arr.flags.writeable = False return arr