From 3d0115cfa5675f84381531e739f0f7c8df90d37f Mon Sep 17 00:00:00 2001 From: Christoph Deil Date: Tue, 11 Jun 2019 23:12:02 +0200 Subject: [PATCH] Remove rotate_polygon function --- regions/_geometry/__init__.py | 2 -- regions/_geometry/rotate_polygon.py | 40 ----------------------------- 2 files changed, 42 deletions(-) delete mode 100644 regions/_geometry/rotate_polygon.py diff --git a/regions/_geometry/__init__.py b/regions/_geometry/__init__.py index 097a5b89..c25e9a17 100644 --- a/regions/_geometry/__init__.py +++ b/regions/_geometry/__init__.py @@ -2,8 +2,6 @@ """ Geometry subpackage for low-level geometry functions. """ - -from .rotate_polygon import * from .circular_overlap import * from .elliptical_overlap import * from .rectangular_overlap import * diff --git a/regions/_geometry/rotate_polygon.py b/regions/_geometry/rotate_polygon.py deleted file mode 100644 index afffa776..00000000 --- a/regions/_geometry/rotate_polygon.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -import numpy as np - -from astropy import units as u -from astropy.coordinates.representation import UnitSphericalRepresentation - -try: - from astropy.coordinates.matrix_utilities import rotation_matrix as rotation_array - def rotation_matrix(*args, **kwargs): - return np.matrix(rotation_array(*args, **kwargs)) -except ImportError: # Astropy < 1.3 - from astropy.coordinates.angles import rotation_matrix - -__all__ = ['rotate_polygon'] - - -def rotate_polygon(lon, lat, lon0, lat0): - """ - Given a polygon with vertices defined by (lon, lat), rotate the polygon - such that the North pole of the spherical coordinates is now at (lon0, - lat0). Therefore, to end up with a polygon centered on (lon0, lat0), the - polygon should initially be drawn around the North pole. - """ - - # Create a representation object - polygon = UnitSphericalRepresentation(lon=lon, lat=lat) - - # Determine rotation matrix to make it so that the circle is centered - # on the correct longitude/latitude. - m1 = rotation_matrix(-(0.5 * np.pi * u.radian - lat0), axis='y') - m2 = rotation_matrix(-lon0, axis='z') - transform_matrix = m2 * m1 - - # Apply 3D rotation - polygon = polygon.to_cartesian() - polygon = polygon.transform(transform_matrix) - polygon = UnitSphericalRepresentation.from_cartesian(polygon) - - return polygon.lon, polygon.lat