summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-12-02 14:26:21 (GMT)
committerAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-12-02 14:32:05 (GMT)
commitbc49609893d79dc12af459dad8750530da37e5ec (patch)
treebcc48c90ccaf913d228ea7cff539121bad7723ef /src
parent855d2702ffff37452ff3bc0e1576d1d17fdb76c2 (diff)
downloadQt-bc49609893d79dc12af459dad8750530da37e5ec.zip
Qt-bc49609893d79dc12af459dad8750530da37e5ec.tar.gz
Qt-bc49609893d79dc12af459dad8750530da37e5ec.tar.bz2
qreal-ization
Adding more wrapper math related functions. This should enable us to have more control over which calls are actually made. Don't worry too much for some "if" statements, the compiler is smart enough to make direct calls to specific math functions. Task-number: QTBUG-4894 Reviewed-by: axis
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmath.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index a9e4378..820f424 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -76,6 +76,16 @@ inline int qFloor(qreal v)
return int(floor(v));
}
+inline qreal qFabs(qreal v)
+{
+#ifdef QT_USE_MATH_H_FLOATS
+ if(sizeof(qreal) == sizeof(float))
+ return fabsf(float(v));
+ else
+#endif
+ return fabs(v);
+}
+
inline qreal qSin(qreal v)
{
#ifdef QT_USE_MATH_H_FLOATS
@@ -96,6 +106,16 @@ inline qreal qCos(qreal v)
return cos(v);
}
+inline qreal qTan(qreal v)
+{
+#ifdef QT_USE_MATH_H_FLOATS
+ if (sizeof(qreal) == sizeof(float))
+ return tanf(float(v));
+ else
+#endif
+ return tan(v);
+}
+
inline qreal qAcos(qreal v)
{
#ifdef QT_USE_MATH_H_FLOATS
@@ -106,6 +126,36 @@ inline qreal qAcos(qreal v)
return acos(v);
}
+inline qreal qAsin(qreal v)
+{
+#ifdef QT_USE_MATH_H_FLOATS
+ if (sizeof(qreal) == sizeof(float))
+ return asinf(float(v));
+ else
+#endif
+ return asin(v);
+}
+
+inline qreal qAtan(qreal v)
+{
+#ifdef QT_USE_MATH_H_FLOATS
+ if(sizeof(qreal) == sizeof(float))
+ return atanf(float(v));
+ else
+#endif
+ return atan(v);
+}
+
+inline qreal qAtan2(qreal x, qreal y)
+{
+#ifdef QT_USE_MATH_H_FLOATS
+ if(sizeof(qreal) == sizeof(float))
+ return atan2f(float(x), float(y));
+ else
+#endif
+ return atan2(x, y);
+}
+
inline qreal qSqrt(qreal v)
{
#ifdef QT_USE_MATH_H_FLOATS
@@ -126,6 +176,13 @@ inline qreal qLn(qreal v)
return log(v);
}
+inline qreal qExp(qreal v)
+{
+ // only one signature
+ // exists, exp(double)
+ return exp(v);
+}
+
inline qreal qPow(qreal x, qreal y)
{
#ifdef QT_USE_MATH_H_FLOATS