| 1 |
/* |
| 2 |
* (C) Copyright 2013 ECMWF. |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 7 |
* granted to it by virtue of its status as an intergovernmental organisation |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include <array> |
| 14 |
#include <iosfwd> |
| 15 |
|
| 16 |
#include "atlas/util/Point.h" |
| 17 |
|
| 18 |
namespace eckit { |
| 19 |
class Parametrisation; |
| 20 |
} |
| 21 |
|
| 22 |
namespace atlas { |
| 23 |
namespace util { |
| 24 |
|
| 25 |
// Compute coordinates of a point on a rotated sphere with specified pole |
| 26 |
class Rotation { |
| 27 |
public: |
| 28 |
Rotation(const PointLonLat& south_pole, double rotation_angle = 0.); |
| 29 |
Rotation(const eckit::Parametrisation&); |
| 30 |
|
| 31 |
bool rotated() const { return rotated_; } |
| 32 |
|
| 33 |
PointLonLat southPole() const { return spole_; } |
| 34 |
PointLonLat northPole() const { return npole_; } |
| 35 |
double rotationAngle() const { return angle_; } |
| 36 |
|
| 37 |
PointLonLat rotate(const PointLonLat&) const; |
| 38 |
PointLonLat unrotate(const PointLonLat&) const; |
| 39 |
|
| 40 |
void rotate(double crd[]) const; |
| 41 |
void unrotate(double crd[]) const; |
| 42 |
|
| 43 |
private: |
| 44 |
void precompute(); |
| 45 |
|
| 46 |
void print(std::ostream&) const; |
| 47 |
friend std::ostream& operator<<(std::ostream&, const Rotation&); |
| 48 |
|
| 49 |
private: |
| 50 |
PointLonLat npole_ = {-180., 90.}; // North Pole |
| 51 |
PointLonLat spole_ = {0., -90.}; // South Pole |
| 52 |
double angle_ = {0.}; |
| 53 |
|
| 54 |
using RotationMatrix = std::array<std::array<double, 3>, 3>; |
| 55 |
|
| 56 |
RotationMatrix rotate_; // rotate matrix |
| 57 |
RotationMatrix unrotate_; // unrotate matrix |
| 58 |
|
| 59 |
bool rotation_angle_only_; |
| 60 |
bool rotated_; |
| 61 |
}; |
| 62 |
|
| 63 |
} // namespace util |
| 64 |
} // namespace atlas |