20#ifndef LIBREPCB_CORE_ANGLE_H
21#define LIBREPCB_CORE_ANGLE_H
26#include "../qtcompat.h"
79 Q_DECLARE_TR_FUNCTIONS(
Angle)
101 explicit Angle(qint32 microdegrees) noexcept
132 const qreal value = std::fmod(degrees * 1e6, 360e6);
135 : qint64(value - qreal(0.5)));
199 qreal
toRad() const noexcept {
return toDeg() / (180.0 / M_PI); }
443 stream << angle.
toDeg();
448 stream << QString(
"Angle(%1°)").arg(angle.
toDeg());
461using Angle3D = std::tuple<Angle, Angle, Angle>;
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
static Angle deg0() noexcept
0 degrees
Definition: angle.h:351
Angle operator-(const Angle &rhs) const
Definition: angle.h:377
static Angle fromDeg(qreal degrees) noexcept
Get an Angle object with a specific angle.
Definition: angle.cpp:120
Angle operator/(const Angle &rhs) const
Definition: angle.h:384
bool operator>=(const Angle &rhs) const
Definition: angle.h:399
static Angle deg180() noexcept
180 degrees
Definition: angle.h:355
Angle & operator-=(const Angle &rhs)
Definition: angle.h:369
qint32 toMicroDeg() const noexcept
Get the angle in microdegrees.
Definition: angle.h:174
bool operator!=(qint32 rhs) const
Definition: angle.h:414
void setAngleDeg(qreal degrees) noexcept
Set the angle in degrees.
Definition: angle.h:131
Angle & operator+=(const Angle &rhs)
Definition: angle.h:365
bool operator>(const Angle &rhs) const
Definition: angle.h:391
static Angle deg315() noexcept
315 degrees
Definition: angle.h:358
bool operator<=(qint32 rhs) const
Definition: angle.h:406
bool operator<(qint32 rhs) const
Definition: angle.h:398
Angle & operator=(const Angle &rhs)
Definition: angle.h:361
~Angle() noexcept
Destructor.
Definition: angle.h:107
Angle & makeAbs() noexcept
Make the angle absolute (mMicrodegrees >= 0)
Definition: angle.cpp:55
Angle operator+(const Angle &rhs) const
Definition: angle.h:373
static Angle deg45() noexcept
45 degrees
Definition: angle.h:352
Angle operator/(qint32 rhs) const
Definition: angle.h:387
bool operator==(qint32 rhs) const
Definition: angle.h:410
bool operator>(qint32 rhs) const
Definition: angle.h:394
qreal toRad() const noexcept
Get the angle in radians.
Definition: angle.h:199
static Angle deg135() noexcept
135 degrees
Definition: angle.h:354
void setAngleMicroDeg(qint32 microdegrees) noexcept
Set the angle in microdegrees.
Definition: angle.h:116
Angle & mapTo180deg() noexcept
Map this Angle object to [-180..+180[ degrees.
Definition: angle.cpp:110
static Angle deg270() noexcept
270 degrees
Definition: angle.h:357
void setAngleRad(qreal radians) noexcept
Set the angle in radians.
Definition: angle.h:163
Angle abs() const noexcept
Get an Angle object with absolute value (mMicrodegrees >= 0)
Definition: angle.cpp:49
static Angle deg90() noexcept
90 degrees
Definition: angle.h:353
Angle & round(const Angle &interval) noexcept
Round the angle to a given interval.
Definition: angle.cpp:81
Angle inverted() const noexcept
Get an Angle object with inverted value.
Definition: angle.cpp:60
bool operator>=(qint32 rhs) const
Definition: angle.h:402
Angle & mapTo0_360deg() noexcept
Map this Angle object to [0..360[ degrees.
Definition: angle.cpp:99
static Angle fromRad(qreal radians) noexcept
Get an Angle object with a specific angle.
Definition: angle.cpp:132
Angle operator-() const
Definition: angle.h:376
Angle(const Angle &angle) noexcept
Copy Constructor.
Definition: angle.h:94
bool operator==(const Angle &rhs) const
Definition: angle.h:407
bool operator!=(const Angle &rhs) const
Definition: angle.h:411
Angle operator*(qint32 rhs) const
Definition: angle.h:383
Angle operator*(const Angle &rhs) const
Definition: angle.h:380
Angle & invert() noexcept
Invert the angle.
Definition: angle.cpp:66
Angle rounded(const Angle &interval) const noexcept
Get an Angle object rounded to a given interval.
Definition: angle.cpp:75
qreal toDeg() const noexcept
Get the Angle in degrees.
Definition: angle.h:181
Angle operator%(const Angle &rhs) const
Definition: angle.h:388
Angle(qint32 microdegrees) noexcept
Constructor with an angle in microdegrees.
Definition: angle.h:101
QString toDegString() const noexcept
Get the angle in degrees as a QString.
Definition: angle.cpp:45
static qint32 degStringToMicrodeg(const QString °rees)
Convert an angle from a QString (in degrees) to an integer (in microdegrees)
Definition: angle.cpp:140
Angle() noexcept
Default Constructor.
Definition: angle.h:87
bool operator<(const Angle &rhs) const
Definition: angle.h:395
Angle mappedTo180deg() const noexcept
Get an Angle object which is mapped to [-180..+180[ degrees.
Definition: angle.cpp:104
qint32 mMicrodegrees
the angle in microdegrees
Definition: angle.h:435
static Angle deg225() noexcept
225 degrees
Definition: angle.h:356
bool operator<=(const Angle &rhs) const
Definition: angle.h:403
void setAngleDeg(const QString °rees)
Set the angle in degrees, represented in a QString.
Definition: angle.h:148
Angle mappedTo0_360deg() const noexcept
Get an Angle object which is mapped to [0..360[ degrees.
Definition: angle.cpp:93
uint Hash
Return type of Qt's qHash() function.
Definition: qtcompat.h:58
Definition: occmodel.cpp:77
QtCompat::Hash qHash(const AttributeKey &key, QtCompat::Hash seed=0) noexcept
Definition: attributekey.h:119
std::tuple< Angle, Angle, Angle > Angle3D
Definition: angle.h:461
QtCompat::Hash qHash(const Angle &key, QtCompat::Hash seed=0) noexcept
Definition: angle.h:452
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition: attributekey.h:109