Use C++ <cmath> instead of <math.h> in math3d autotests

Change-Id: I2e13ec190ec42ac7732ce9ed3ca5567f637beb1e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
This commit is contained in:
Konstantin Ritt 2015-02-26 17:45:11 +04:00
parent d07166af64
commit 4ed795df24
3 changed files with 10 additions and 9 deletions

View File

@ -2279,9 +2279,9 @@ void tst_QMatrixNxN::rotate4x4_data()
float y = 2.0f;
float z = -6.0f;
float angle = -45.0f;
float c = qCos(angle * M_PI / 180.0f);
float s = qSin(angle * M_PI / 180.0f);
float len = sqrtf(x * x + y * y + z * z);
float c = std::cos(angle * M_PI / 180.0f);
float s = std::sin(angle * M_PI / 180.0f);
float len = std::sqrt(x * x + y * y + z * z);
float xu = x / len;
float yu = y / len;
float zu = z / len;

View File

@ -237,7 +237,7 @@ void tst_QQuaternion::length_data()
QTest::newRow("-1y") << 0.0f << -1.0f << 0.0f << 0.0f << 1.0f;
QTest::newRow("-1z") << 0.0f << 0.0f << -1.0f << 0.0f << 1.0f;
QTest::newRow("-1w") << 0.0f << 0.0f << 0.0f << -1.0f << 1.0f;
QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << sqrtf(16.0f);
QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << std::sqrt(16.0f);
}
void tst_QQuaternion::length()
{
@ -710,8 +710,9 @@ void tst_QQuaternion::fromAxisAndAngle()
// http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56
// to calculate the answer we expect to get.
QVector3D vector = QVector3D(x1, y1, z1).normalized();
float sin_a = sinf((angle * M_PI / 180.0) / 2.0);
float cos_a = cosf((angle * M_PI / 180.0) / 2.0);
const float a = (angle * M_PI / 180.0) / 2.0;
const float sin_a = std::sin(a);
const float cos_a = std::cos(a);
QQuaternion result(cos_a,
(vector.x() * sin_a),
(vector.y() * sin_a),

View File

@ -667,7 +667,7 @@ void tst_QVectorND::length2_data()
QTest::newRow("1y") << 0.0f << 1.0f << 1.0f;
QTest::newRow("-1x") << -1.0f << 0.0f << 1.0f;
QTest::newRow("-1y") << 0.0f << -1.0f << 1.0f;
QTest::newRow("two") << 2.0f << -2.0f << sqrtf(8.0f);
QTest::newRow("two") << 2.0f << -2.0f << std::sqrt(8.0f);
}
void tst_QVectorND::length2()
{
@ -695,7 +695,7 @@ void tst_QVectorND::length3_data()
QTest::newRow("-1x") << -1.0f << 0.0f << 0.0f << 1.0f;
QTest::newRow("-1y") << 0.0f << -1.0f << 0.0f << 1.0f;
QTest::newRow("-1z") << 0.0f << 0.0f << -1.0f << 1.0f;
QTest::newRow("two") << 2.0f << -2.0f << 2.0f << sqrtf(12.0f);
QTest::newRow("two") << 2.0f << -2.0f << 2.0f << std::sqrt(12.0f);
}
void tst_QVectorND::length3()
{
@ -727,7 +727,7 @@ void tst_QVectorND::length4_data()
QTest::newRow("-1y") << 0.0f << -1.0f << 0.0f << 0.0f << 1.0f;
QTest::newRow("-1z") << 0.0f << 0.0f << -1.0f << 0.0f << 1.0f;
QTest::newRow("-1w") << 0.0f << 0.0f << 0.0f << -1.0f << 1.0f;
QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << sqrtf(16.0f);
QTest::newRow("two") << 2.0f << -2.0f << 2.0f << 2.0f << std::sqrt(16.0f);
}
void tst_QVectorND::length4()
{