summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmath.h20
-rw-r--r--src/corelib/kernel/qmath.qdoc34
2 files changed, 54 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index 57314901e8..e7b6ab9c0e 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -233,6 +233,17 @@ Q_DECL_CONSTEXPR inline double qDegreesToRadians(double degrees)
return degrees * (M_PI / 180);
}
+Q_DECL_CONSTEXPR inline long double qDegreesToRadians(long double degrees)
+{
+ return degrees * (M_PI / 180);
+}
+
+template <typename T, std::enable_if_t<std::is_integral_v<T>, bool> = true>
+Q_DECL_CONSTEXPR inline double qDegreesToRadians(T degrees)
+{
+ return qDegreesToRadians(static_cast<double>(degrees));
+}
+
Q_DECL_CONSTEXPR inline float qRadiansToDegrees(float radians)
{
return radians * float(180/M_PI);
@@ -243,6 +254,15 @@ Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians)
return radians * (180 / M_PI);
}
+Q_DECL_CONSTEXPR inline long double qRadiansToDegrees(long double radians)
+{
+ return radians * (180 / M_PI);
+}
+
+// A qRadiansToDegrees(Integral) overload isn't here; it's extremely
+// questionable that someone is manipulating quantities in radians
+// using integral datatypes...
+
namespace QtPrivate {
constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v) {
v |= v >> 1;
diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc
index 82a4ae85a5..b0a52a4a52 100644
--- a/src/corelib/kernel/qmath.qdoc
+++ b/src/corelib/kernel/qmath.qdoc
@@ -205,6 +205,30 @@
*/
/*!
+ \fn long double qDegreesToRadians(long double degrees)
+ \relates <QtMath>
+ \since 6.0
+
+ This function converts the \a degrees in double to radians.
+
+ \sa qRadiansToDegrees()
+*/
+
+/*!
+ \fn template <typename Integral> double qDegreesToRadians(Integral degrees)
+ \relates <QtMath>
+ \since 6.0
+
+ This function converts the \a degrees in double to radians;
+ the angle is casted to a double before the conversion.
+
+ This function participates in overload resolution if and only if
+ \c Integral is an integral type.
+
+ \sa qRadiansToDegrees()
+*/
+
+/*!
\fn float qRadiansToDegrees(float radians)
\relates <QtMath>
\since 5.1
@@ -233,6 +257,16 @@
*/
/*!
+ \fn long double qRadiansToDegrees(long double radians)
+ \relates <QtMath>
+ \since 6.0
+
+ This function converts the \a radians in double to degrees.
+
+ \sa qDegreesToRadians()
+*/
+
+/*!
\fn quint32 qNextPowerOfTwo(quint32 value)
\relates <QtMath>
\since 5.4