12 #ifndef ECL_GEOMETRY_ANGLE_HPP_
13 #define ECL_GEOMETRY_ANGLE_HPP_
42 static const T rads_to_degs = 180.0/
pi;
43 return radians*rads_to_degs;
55 static const T degs_to_rads =
pi/180.0;
56 return degrees*degs_to_rads;
112 template <
class T,
typename Enable =
void>
135 template <
typename T>
141 typedef ecl::linear_algebra::Matrix<T,2,2> RotationMatrix;
150 Angle(
const T &angle = 0.0) : value(angle) {
wrap_angle(value); }
155 Angle(
const RotationMatrix &rotation) {
156 value = std::atan2(rotation(1,0),rotation(0,0));
168 const Angle<T>& operator=(
const T &angle);
180 Angle<T> operator+(
const T &angle)
const;
197 void operator+=(
const T &angle);
205 void operator+=(
const Angle<T> &angle);
214 Angle<T> operator-(
const T &angle)
const;
231 void operator-=(
const T &angle);
239 void operator-=(
const Angle<T> &angle);
248 Angle<T> operator*(
const T &scalar)
const;
256 void operator*=(
const T &scalar);
270 operator const T&()
const {
return value; }
287 RotationMatrix rotationMatrix()
const {
288 T c = std::cos(value);
289 T s = std::sin(value);
290 return (RotationMatrix() << c, -s, s, c).finished();
306 static Angle<T> Degrees(
const T &angle);
320 static Angle<T> Radians(
const T &angle);
334 template <
typename T>
335 T Angle<T, typename enable_if<is_float<T> >::type>::degrees() {
339 template <
typename T>
340 const Angle<T>& Angle<T, typename enable_if<is_float<T> >::type>::operator=(
const T &angle) {
350 template <
typename T>
351 Angle<T> Angle<T, typename enable_if<is_float<T> >::type>::operator+(
const T &angle)
const {
355 template <
typename T>
356 Angle<T> Angle<T, typename enable_if<is_float<T> >::type>::operator+(
const Angle<T> &angle)
const {
357 return Angle<T>(
wrap_angle(value+angle.value));
360 template <
typename T>
361 void Angle<T, typename enable_if<is_float<T> >::type>::operator+=(
const T &angle) {
366 template <
typename T>
367 void Angle<T, typename enable_if<is_float<T> >::type>::operator+=(
const Angle<T> &angle) {
368 value += angle.value;
372 template <
typename T>
373 Angle<T> Angle<T, typename enable_if<is_float<T> >::type>::operator-(
const T &angle)
const {
377 template <
typename T>
378 Angle<T> Angle<T, typename enable_if<is_float<T> >::type>::operator-(
const Angle<T> &angle)
const {
379 return Angle<T>(
wrap_angle(value-angle.value));
382 template <
typename T>
383 void Angle<T, typename enable_if<is_float<T> >::type>::operator-=(
const T &angle) {
388 template <
typename T>
389 void Angle<T, typename enable_if<is_float<T> >::type>::operator-=(
const Angle<T> &angle) {
390 value -= angle.value;
394 template <
typename T>
395 Angle<T> Angle<T, typename enable_if<is_float<T> >::type>::operator*(
const T &scalar)
const {
399 template <
typename T>
400 void Angle<T, typename enable_if<is_float<T> >::type>::operator*=(
const T &scalar) {
409 template <
typename T>
410 Angle<T> Angle<T, typename enable_if<is_float<T> >::type>::Degrees(
const T &angle) {
414 template <
typename T>
415 Angle<T> Angle<T, typename enable_if<is_float<T> >::type>::Radians(
const T &angle) {
416 return Angle<T>(angle);