diff --git a/masque/utils/transform.py b/masque/utils/transform.py index 90647b1..62e0f1e 100644 --- a/masque/utils/transform.py +++ b/masque/utils/transform.py @@ -28,8 +28,9 @@ 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): + # If this was a manhattan rotation, round to remove some inaccuracies in sin & cos + # cos(4*theta) is 1 for any multiple of pi/2. + if numpy.isclose(numpy.cos(4 * theta), 1, atol=1e-12): arr = numpy.round(arr) arr.flags.writeable = False