| 291 | } |
| 292 | |
| 293 | void DatapickerTest::mapPolarInRadiansToCartesian() { |
| 294 | DatapickerImage::ReferencePoints points; |
| 295 | points.type = DatapickerImage::GraphType::PolarInRadians; |
| 296 | points.logicalPos[0].setX(1); |
| 297 | points.logicalPos[0].setY(0); |
| 298 | points.logicalPos[1].setX(3); |
| 299 | points.logicalPos[1].setY(2.1f); |
| 300 | points.logicalPos[2].setX(5); |
| 301 | points.logicalPos[2].setY(3.8f); |
| 302 | points.scenePos[0].setX(6.21); |
| 303 | points.scenePos[0].setY(7.23); |
| 304 | points.scenePos[1].setX(-51.2); |
| 305 | points.scenePos[1].setY(3234); |
| 306 | points.scenePos[2].setX(-23); |
| 307 | points.scenePos[2].setY(+5e6); |
| 308 | |
| 309 | Transform t; |
| 310 | QCOMPARE(t.mapTypeToCartesian(points), true); |
| 311 | VALUES_EQUAL(t.x[0], 1.); |
| 312 | VALUES_EQUAL(t.y[0], 0.); |
| 313 | |
| 314 | // TODO: VALUES_EQUAL doesn't work for the next comparions since the precision 1.e-7 is too high for the numerical error involved here. |
| 315 | // to improve the precision we need to get rid of QVector3D using floats internally and to switch to doubles. For now, just use a somewhat |
| 316 | // lower precision here since it's not essential. |
| 317 | // VALUES_EQUAL(t.x[1], -1.5145383137996); // precision seems to be not correct. Referece value is correct |
| 318 | double v1 = t.x[1]; |
| 319 | double ref = -1.5145383137996; |
| 320 | QVERIFY2(nsl_math_approximately_equal_eps(v1, ref, 1.e-5) == true, |
| 321 | qPrintable(QStringLiteral("v1:%1, ref:%2").arg(v1, 0, 'g', 15, QLatin1Char(' ')).arg(ref, 0, 'g', 15, QLatin1Char(' ')))); |
| 322 | |
| 323 | VALUES_EQUAL(t.y[1], 2.5896280999466); |
| 324 | VALUES_EQUAL(t.x[2], -3.9548385595721); |
| 325 | VALUES_EQUAL(t.y[2], -3.0592894547136); |
| 326 | VALUES_EQUAL(t.X[0], 6.21); |
| 327 | VALUES_EQUAL(t.Y[0], 7.23); |
| 328 | VALUES_EQUAL(t.X[1], -51.2); |
| 329 | VALUES_EQUAL(t.Y[1], 3234.); |
| 330 | VALUES_EQUAL(t.X[2], -23.); |
| 331 | VALUES_EQUAL(t.Y[2], +5.e6); |
| 332 | } |
| 333 | |
| 334 | void DatapickerTest::mapPolarInDegreeToCartesian() { |
| 335 | DatapickerImage::ReferencePoints points; |
nothing calls this directly
no test coverage detected