summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins@kdab.com>2015-03-28 17:20:44 +0000
committerSérgio Martins <sergio.martins@kdab.com>2015-03-30 20:14:49 +0000
commit67bc52239aba6daa7f9b7659cc05074635fde7e2 (patch)
treec9a3bea8717e06f67a76a8890f45fc7e1cbc473f
parent5793de3d3a5ae3f5683289adb90ed6201c269301 (diff)
Fix QNX 6.6 build, use the q* version of math functions
genericrotationsensor.cpp:85:37: error: 'sqrt' was not declared in this scope Change-Id: I871b88130debdfd0a64421e4da8a451b586e7ba6 Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
-rw-r--r--src/plugins/sensors/generic/genericrotationsensor.cpp6
-rw-r--r--src/plugins/sensors/generic/generictiltsensor.cpp12
2 files changed, 9 insertions, 9 deletions
diff --git a/src/plugins/sensors/generic/genericrotationsensor.cpp b/src/plugins/sensors/generic/genericrotationsensor.cpp
index af2800c8..af2c3cfb 100644
--- a/src/plugins/sensors/generic/genericrotationsensor.cpp
+++ b/src/plugins/sensors/generic/genericrotationsensor.cpp
@@ -82,8 +82,8 @@ bool genericrotationsensor::filter(QSensorReading *reading)
// Note that the formula used come from this document:
// http://www.freescale.com/files/sensors/doc/app_note/AN3461.pdf
- pitch = qAtan(y / sqrt(x*x + z*z)) * RADIANS_TO_DEGREES;
- roll = qAtan(x / sqrt(y*y + z*z)) * RADIANS_TO_DEGREES;
+ pitch = qAtan(y / qSqrt(x*x + z*z)) * RADIANS_TO_DEGREES;
+ roll = qAtan(x / qSqrt(y*y + z*z)) * RADIANS_TO_DEGREES;
// Roll is a left-handed rotation but we need right-handed rotation
roll = -roll;
@@ -92,7 +92,7 @@ bool genericrotationsensor::filter(QSensorReading *reading)
// Note that theta is defined as the angle of the Z axis relative
// to gravity (see referenced document). It's negative when the
// face of the device points downward.
- qreal theta = qAtan(sqrt(x*x + y*y) / z) * RADIANS_TO_DEGREES;
+ qreal theta = qAtan(qSqrt(x*x + y*y) / z) * RADIANS_TO_DEGREES;
if (theta < 0) {
if (roll > 0)
roll = 180 - roll;
diff --git a/src/plugins/sensors/generic/generictiltsensor.cpp b/src/plugins/sensors/generic/generictiltsensor.cpp
index f6dafb43..a2525a82 100644
--- a/src/plugins/sensors/generic/generictiltsensor.cpp
+++ b/src/plugins/sensors/generic/generictiltsensor.cpp
@@ -80,7 +80,7 @@ void GenericTiltSensor::stop()
*/
static inline qreal calcPitch(double Ax, double Ay, double Az)
{
- return -qAtan2(Ax, sqrt(Ay * Ay + Az * Az));
+ return -qAtan2(Ax, qSqrt(Ay * Ay + Az * Az));
}
/*
@@ -91,7 +91,7 @@ static inline qreal calcPitch(double Ax, double Ay, double Az)
*/
static inline qreal calcRoll(double Ax, double Ay, double Az)
{
- return qAtan2(Ay, (sqrt(Ax * Ax + Az * Az)));
+ return qAtan2(Ay, (qSqrt(Ax * Ax + Az * Az)));
}
void GenericTiltSensor::calibrate()
@@ -132,15 +132,15 @@ bool GenericTiltSensor::filter(QAccelerometerReading *reading)
qreal xrot = roll - calibratedRoll;
qreal yrot = pitch - calibratedPitch;
//get angle between 0 and 180 or 0 -180
- qreal aG = 1 * sin(xrot);
- qreal aK = 1 * cos(xrot);
+ qreal aG = 1 * qSin(xrot);
+ qreal aK = 1 * qCos(xrot);
xrot = qAtan2(aG, aK);
if (xrot > M_PI_2)
xrot = M_PI - xrot;
else if (xrot < -M_PI_2)
xrot = -(M_PI + xrot);
- aG = 1 * sin(yrot);
- aK = 1 * cos(yrot);
+ aG = 1 * qSin(yrot);
+ aK = 1 * qCos(yrot);
yrot = qAtan2(aG, aK);
if (yrot > M_PI_2)
yrot = M_PI - yrot;