summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-11-10 20:04:41 (GMT)
committerAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-11-11 12:47:42 (GMT)
commit72c170b64056a59dce9f849a5789d2968071f7b9 (patch)
tree0fe45271f034f845b3f3cf7ceeeb856c1b52f3bd /src/corelib/kernel
parentc327076817dad875bd057bf28eab36b1d4e732ef (diff)
downloadQt-72c170b64056a59dce9f849a5789d2968071f7b9.zip
Qt-72c170b64056a59dce9f849a5789d2968071f7b9.tar.gz
Qt-72c170b64056a59dce9f849a5789d2968071f7b9.tar.bz2
Revert "Using qreal more consistently in code (prevent misuse of double)"
This reverts commit 676780d515cedca85829ae962e4f501c5e5b6581. Conflicts: src/gui/painting/qblendfunctions.cpp
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qmath.h45
1 files changed, 10 insertions, 35 deletions
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index ef3a4b0..a9e4378 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -45,7 +45,6 @@
#include <math.h>
#include <QtCore/qglobal.h>
-#include <private/qnumeric_p.h>
QT_BEGIN_HEADER
@@ -107,16 +106,6 @@ 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 qSqrt(qreal v)
{
#ifdef QT_USE_MATH_H_FLOATS
@@ -147,42 +136,28 @@ inline qreal qPow(qreal x, qreal y)
return pow(x, y);
}
+#ifndef M_PI
+#define M_PI (3.14159265358979323846)
+#endif
+
inline qreal qFastSin(qreal x)
{
- int si = int(x * (qreal(0.5) * QT_SINE_TABLE_SIZE / Q_PI)); // Would be more accurate with qRound, but slower.
- qreal d = x - si * (qreal(2.0) * Q_PI / QT_SINE_TABLE_SIZE);
+ int si = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
+ qreal d = x - si * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
int ci = si + QT_SINE_TABLE_SIZE / 4;
si &= QT_SINE_TABLE_SIZE - 1;
ci &= QT_SINE_TABLE_SIZE - 1;
- return qt_sine_table[si] + (qt_sine_table[ci] - qreal(0.5) * qt_sine_table[si] * d) * d;
+ return qt_sine_table[si] + (qt_sine_table[ci] - 0.5 * qt_sine_table[si] * d) * d;
}
inline qreal qFastCos(qreal x)
{
- int ci = int(x * (qreal(0.5) * QT_SINE_TABLE_SIZE / Q_PI)); // Would be more accurate with qRound, but slower.
- qreal d = x - ci * (qreal(2.0) * Q_PI / QT_SINE_TABLE_SIZE);
+ int ci = int(x * (0.5 * QT_SINE_TABLE_SIZE / M_PI)); // Would be more accurate with qRound, but slower.
+ qreal d = x - ci * (2.0 * M_PI / QT_SINE_TABLE_SIZE);
int si = ci + QT_SINE_TABLE_SIZE / 4;
si &= QT_SINE_TABLE_SIZE - 1;
ci &= QT_SINE_TABLE_SIZE - 1;
- return qt_sine_table[si] - (qt_sine_table[ci] + qreal(0.5) * qt_sine_table[si] * d) * d;
-}
-
-inline qreal qFabs(qreal x)
-{
-#ifdef QT_USE_MATH_H_FLOATS
- if(sizeof(qreal) == sizeof(float))
- return fabsf(x);
-#endif
- return fabs(x);
-}
-
-inline qreal qAtan2(qreal x, qreal y)
-{
-#ifdef QT_USE_MATH_H_FLOATS
- if(sizeof(qreal) == sizeof(float))
- return atan2f(x, y);
-#endif
- return atan2(x, y);
+ return qt_sine_table[si] - (qt_sine_table[ci] + 0.5 * qt_sine_table[si] * d) * d;
}
QT_END_NAMESPACE