20#ifndef LIBREPCB_CORE_ANGLE_H
21#define LIBREPCB_CORE_ANGLE_H
77 Q_DECLARE_TR_FUNCTIONS(
Angle)
99 explicit Angle(qint32 microdegrees) noexcept
130 const qreal value = std::fmod(degrees * 1e6, 360e6);
133 : qint64(value - qreal(0.5)));
197 qreal
toRad() const noexcept {
return toDeg() / (180.0 / M_PI); }
441 stream << angle.
toDeg();
446 stream << QString(
"Angle(%1°)").arg(angle.
toDeg());
450inline std::size_t
qHash(
const Angle& key, std::size_t seed = 0) noexcept {
458using Angle3D = std::tuple<Angle, Angle, Angle>;
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
static Angle deg0() noexcept
0 degrees
Definition angle.h:349
Angle operator-(const Angle &rhs) const
Definition angle.h:375
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:382
bool operator>=(const Angle &rhs) const
Definition angle.h:397
static Angle deg180() noexcept
180 degrees
Definition angle.h:353
Angle & operator-=(const Angle &rhs)
Definition angle.h:367
qint32 toMicroDeg() const noexcept
Get the angle in microdegrees.
Definition angle.h:172
bool operator!=(qint32 rhs) const
Definition angle.h:412
void setAngleDeg(qreal degrees) noexcept
Set the angle in degrees.
Definition angle.h:129
Angle & operator+=(const Angle &rhs)
Definition angle.h:363
bool operator>(const Angle &rhs) const
Definition angle.h:389
static Angle deg315() noexcept
315 degrees
Definition angle.h:356
bool operator<=(qint32 rhs) const
Definition angle.h:404
bool operator<(qint32 rhs) const
Definition angle.h:396
Angle & operator=(const Angle &rhs)
Definition angle.h:359
~Angle() noexcept
Destructor.
Definition angle.h:105
Angle & makeAbs() noexcept
Make the angle absolute (mMicrodegrees >= 0)
Definition angle.cpp:55
Angle operator+(const Angle &rhs) const
Definition angle.h:371
static Angle deg45() noexcept
45 degrees
Definition angle.h:350
Angle operator/(qint32 rhs) const
Definition angle.h:385
bool operator==(qint32 rhs) const
Definition angle.h:408
bool operator>(qint32 rhs) const
Definition angle.h:392
qreal toRad() const noexcept
Get the angle in radians.
Definition angle.h:197
static Angle deg135() noexcept
135 degrees
Definition angle.h:352
void setAngleMicroDeg(qint32 microdegrees) noexcept
Set the angle in microdegrees.
Definition angle.h:114
Angle & mapTo180deg() noexcept
Map this Angle object to [-180..+180[ degrees.
Definition angle.cpp:110
static Angle deg270() noexcept
270 degrees
Definition angle.h:355
void setAngleRad(qreal radians) noexcept
Set the angle in radians.
Definition angle.h:161
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:351
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:400
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:374
Angle(const Angle &angle) noexcept
Copy Constructor.
Definition angle.h:92
bool operator==(const Angle &rhs) const
Definition angle.h:405
bool operator!=(const Angle &rhs) const
Definition angle.h:409
Angle operator*(qint32 rhs) const
Definition angle.h:381
Angle operator*(const Angle &rhs) const
Definition angle.h:378
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:179
Angle operator%(const Angle &rhs) const
Definition angle.h:386
Angle(qint32 microdegrees) noexcept
Constructor with an angle in microdegrees.
Definition angle.h:99
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:85
bool operator<(const Angle &rhs) const
Definition angle.h:393
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:433
static Angle deg225() noexcept
225 degrees
Definition angle.h:354
bool operator<=(const Angle &rhs) const
Definition angle.h:401
void setAngleDeg(const QString °rees)
Set the angle in degrees, represented in a QString.
Definition angle.h:146
Angle mappedTo0_360deg() const noexcept
Get an Angle object which is mapped to [0..360[ degrees.
Definition angle.cpp:93
Definition occmodel.cpp:76
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:118
std::tuple< Angle, Angle, Angle > Angle3D
Definition angle.h:458
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition attributekey.h:108