2018-01-20 20:13:56 +01:00
|
|
|
#ifndef ANGULARUNITS_H
|
|
|
|
#define ANGULARUNITS_H
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <QDebug>
|
2021-06-17 21:58:25 +02:00
|
|
|
#include "common/coordinates.h"
|
2018-01-20 20:13:56 +01:00
|
|
|
|
|
|
|
class AngularUnits
|
|
|
|
{
|
|
|
|
public:
|
2018-01-22 00:28:58 +01:00
|
|
|
AngularUnits() : _code(0), _f(NAN) {}
|
2018-01-20 20:13:56 +01:00
|
|
|
AngularUnits(int code);
|
2021-06-17 21:58:25 +02:00
|
|
|
AngularUnits(double val) : _code(0), _f(rad2deg(val)) {}
|
2018-01-20 20:13:56 +01:00
|
|
|
|
2020-04-21 23:26:35 +02:00
|
|
|
bool operator==(const AngularUnits &other) const
|
2020-11-19 21:47:45 +01:00
|
|
|
{
|
|
|
|
if (_code == 9110)
|
|
|
|
return (other._code == 9110);
|
|
|
|
else
|
|
|
|
return (_f == other._f);
|
|
|
|
}
|
2020-04-21 23:26:35 +02:00
|
|
|
|
2018-01-20 20:13:56 +01:00
|
|
|
bool isNull() const {return std::isnan(_f);}
|
|
|
|
bool isValid() const {return !std::isnan(_f);}
|
|
|
|
|
2018-01-22 00:28:58 +01:00
|
|
|
double toDegrees(double val) const;
|
|
|
|
double fromDegrees(double val) const;
|
2018-01-20 20:13:56 +01:00
|
|
|
|
2018-02-13 23:03:18 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2018-01-20 20:13:56 +01:00
|
|
|
friend QDebug operator<<(QDebug dbg, const AngularUnits &au);
|
2018-02-13 23:03:18 +01:00
|
|
|
#endif // QT_NO_DEBUG
|
2018-01-20 20:13:56 +01:00
|
|
|
private:
|
2018-01-22 00:28:58 +01:00
|
|
|
int _code;
|
2018-01-20 20:13:56 +01:00
|
|
|
double _f;
|
|
|
|
};
|
|
|
|
|
2018-02-13 23:03:18 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2018-01-20 20:13:56 +01:00
|
|
|
QDebug operator<<(QDebug dbg, const AngularUnits &au);
|
2018-02-13 23:03:18 +01:00
|
|
|
#endif // QT_NO_DEBUG
|
2018-01-20 20:13:56 +01:00
|
|
|
|
|
|
|
#endif // ANGULARUNITS_H
|