def _rotate_polygon(lon, lat, lon0, lat0):
 polygon = UnitSphericalRepresentation(lon=lon, lat=lat)
 m1 = rotation_matrix((- (((0.5 * np.pi) * u.radian) - lat0)), axis='y')
 m2 = rotation_matrix((- lon0), axis='z')
 transform_matrix = matrix_product(m2, m1)
 polygon = polygon.to_cartesian()
 polygon = polygon.transform(transform_matrix)
 polygon = UnitSphericalRepresentation.from_cartesian(polygon)
 return (polygon.lon, polygon.lat)

def _rotate_polygon ( lon , lat , lon0 , lat0 ) : polygon = UnitSphericalRepresentation ( lon = lon , lat = lat ) m1 = rotation_matrix ( ( - ( ( ( 0.5 * np . pi ) * u . radian ) - lat0 ) ) , axis = 'y' ) m2 = rotation_matrix ( ( - lon0 ) , axis = 'z' ) transform_matrix = matrix_product ( m2 , m1 ) polygon = polygon . to_cartesian ( ) polygon = polygon . transform ( transform_matrix ) polygon = UnitSphericalRepresentation . from_cartesian ( polygon ) return ( polygon . lon , polygon . lat )
given a polygon with vertices defined by .