summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/math3d/qquaternion/tst_qquaternion.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Mark all of Qt as free of Q_FOREACH, except where it isn'tMarc Mutz2023-08-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | The density of Q_FOREACH uses in this and some other modules is still extremely high, too high for anyone to tackle in a short amount of time. Even if they're not concentrated in just a few TUs, we need to make progress on a global QT_NO_FOREACH default, so grab the nettle and stick to our strategy: Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the #undef QT_NO_FOREACH to indicate that these actually test the macro. Task-number: QTBUG-115839 Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix tst_QQuaternion's duplicate test tagsEdward Welbourne2022-10-111-25/+9
| | | | | | | | Having the same test tag for two rows of a data table makes the report less useful. We also intend to forbid doing that. Change-Id: I67ec32514b6550f4f97610a2140f1383d0d85b23 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-27/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtGui/math3d: Fix QQuaternion::getEulerAngles for GimbalLock casesYuya Nishihara2022-01-161-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is heavily inspired by the patch written by Inho Lee <inho.lee@qt.io>, which says "There is a precision problem in the previous algorithm when checking pitch value. (In the case that the rotation on the X-axis makes Gimbal lock.)" In order to work around the precision problem, this patch does: 1. switch to the algorithm described in the inline comment to make the story simple. 2. forcibly normalize the {x, y, z, w} components to eliminate fractional errors. 3. set threshold to avoid hidden division by cos(pitch) =~ 0. From my testing which compares dot product of the original quaternion and the one recreated from Euler angles, calculation within float range seems okay. (abs(normalize(q_orig) * normalize(q_roundtrip)) >= 0.99999) Many thanks to Inho Lee for the original patch and discussion about rounding errors. Fixes: QTBUG-72103 Pick-to: 6.3 6.2 5.15 Change-Id: I8995e4affe603111ff2303a0dfcbdb0b1ae03f10 Reviewed-by: Yuya Nishihara <yuya@tcha.org> Reviewed-by: Inho Lee <inho.lee@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtGui/math3d : Fix QQuaternion::getEulerAnglesInho Lee2021-06-011-8/+28
| | | | | | | | | | | When rotating M_PI_2 based on x-axis, quaternion to euler conversion makes NaN for the x-rotation value. This patch fixes this corner case. Fixes: QTBUG-93600 Pick-to: 6.1 6.0 5.15 Change-Id: Ice321a80ad90dba9cf3ee3a14ec7d3d047c21bd3 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix warnings about lossy double/float conversion in testsVolker Hilsheimer2021-04-111-1/+1
| | | | | | | | | QVectorND, QQuaternion, and QColor all operate on floats rather than qreal or double, so explicit use float literals in the tests. Pick-to: 6.1 Change-Id: If12cc12ddd9cd8219f3d78bf24e1400921e26c2b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+1
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use QCOMPARE(,) in preference to QVERIFY(qFuzzyCompare(,))Edward Welbourne2020-11-271-24/+24
| | | | | | | | | The former also does fuzzy comparison, but it reports what the values were, if the test ever fails. Change-Id: I36ecda1f69bf3f430c904b37cd8c3a23201ab7e2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Another round of replacing 0 with nullptrAllan Sandfeld Jensen2020-10-071-1/+1
| | | | | | | | | This time based on grepping to also include documentation, tests and examples previously missed by the automatic tool. Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Remove deprecated method QQuaternion::conjugateMarcel Krems2020-09-071-7/+4
| | | | | Change-Id: If539e47618357ef329925033842f266447632e6f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Deprecate the static int based API in QMetaTypeLars Knoll2020-08-241-3/+2
| | | | | | | | | | | | | And remove one of the type id to name mapping that still existed in QMetaType. QMetaTypeInterface can provide that, so there's no need to have a second copy of the data. qMetaTypeTypeInternal() can still map all the names of all builtin types to ids. That functionality is for now still required by moc and can't be removed yet. Change-Id: Ib4f8e9c71e1e7d99d52da9e44477c9a1f1805e57 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove usages of deprecated APIs of qtbase/guiSona Kurazyan2019-07-131-0/+3
| | | | | | | | | | | | | | | - Replaced the usages of deprecated APIs by corresponding alternatives in the library code and documentation. - Modified the tests to make them build when deprecated APIs disabled: * Made the the parts of the tests testing the deprecated APIs to be compiled conditionally, only when the corresponding methods are enabled. * If the test-case tests only the deprecated API, but not the corresponding replacement, added tests for the replacement. Change-Id: Ic38245015377fc0c8127eb5458c184ffd4b450f1 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use qRadiansToDegrees() and qDegreesToRadians() more widelyEdward Welbourne2017-07-051-1/+1
| | | | | | | | | | | | | | | | Especially in examples, where we should show off our convenience functions, prefer calling these functions over doing arithmetic with M_PI (or approximations thereto) and 180 (give or take simple factors). This incidentally documents what's going on, just by the name of the function used (and reveals at least one place where variables were misnamed; the return from atan is in radians, *not* degrees). Task-number: QTBUG-58083 Change-Id: I6e5d66721cafab423378f970af525400423e971e Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Tests: Fix single-character string literals.Friedemann Kleint2015-10-131-6/+6
| | | | | | | Use character literals where applicable. Change-Id: I1a026c320079ee5ca6f70be835d5a541deee2dd1 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* tests/auto/gui: Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b).Friedemann Kleint2015-07-311-10/+10
| | | | | | | | | | | | - Replace Q[TRY]_VERIFY(pointer == 0) by Q[TRY]_VERIFY(!pointer). - Replace Q[TRY]_VERIFY(smartPointer == 0) by Q[TRY]_VERIFY(smartPointer.isNull()). - Replace Q[TRY]_VERIFY(a == b) by Q[TRY]_COMPARE(a, b) and add casts where necessary. The values will then be logged should a test fail. Change-Id: I624deb320c378c18a29b3707f48583d53bfd5186 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
* Introduce QQuaternion::fromDirection()Konstantin Ritt2015-04-071-0/+94
| | | | | | | | | | ...which constructs a quaternion using specified forward and upward directions, so that the resulting Z axis "faces" a given forward direction. Change-Id: Ib77b8ab5c359a4880b0d946face87026acdc6f0b Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Michael Krasnyk <michael.krasnyk@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Introduce QQuaternion::rotationTo(vecFrom, vecTo)Konstantin Ritt2015-03-071-0/+60
| | | | | | | | | which returns the shortest arc quaternion to rotate vector from to the destination vector to. Change-Id: Ibd7a746789ecdfe6f7fe17e4ac9049f7ac46560d Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* [QQuaternion] Add a way to convert to/from orthonormal axesKonstantin Ritt2015-03-071-28/+95
| | | | | | | | It is just a convenience wrapper around convertion to/from the rotation matrix. Change-Id: I27511b43866827172960b0152f1c7b65da857f6f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Introduce QQuaternion::dotProduct()Konstantin Ritt2015-03-051-0/+55
| | | | | Change-Id: I14b9857ca0a43808b7d536fc258a6bb10f611211 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
* Use C++ <cmath> instead of <math.h> in math3d autotestsKonstantin Ritt2015-02-261-3/+4
| | | | | Change-Id: I2e13ec190ec42ac7732ce9ed3ca5567f637beb1e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
* [QQuaternion] Fix naming of the new methodsKonstantin Ritt2015-02-261-3/+3
| | | | | | | | | | | According to the Qt naming policy, methods that return value(s) via the mutable parameter(s) should have "get" prefix to mention that. [ChangeLog][QtGui][QQuaternion] Added methods to convert a quaternion to/from Euler angles and to/from rotation matrix. Change-Id: I95704e1f4623dc4ca54cd237ea203539fb60d452 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* [QQuaternion] Introduce to/from euler angles conversion routinesKonstantin Ritt2015-02-141-0/+112
| | | | | Change-Id: I26c0a9d1ce9258048cf44eed5b5238920c2317b1 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* [QQuaternion] Introduce toAxisAndAngle()Konstantin Ritt2015-02-141-0/+20
| | | | | | | | | This operation is the exact opposite to QQuaternion::fromAxisAndAngle() (so that it is a way to extract the axis and angle values suitable to create the same quaternion via QQuaternion::fromAxisAndAngle()). Change-Id: I41fda58f5fb2b867cccd6b2faf58ab671fa070da Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* [QQuaternion] Introduce to/from rotation matrix conversion routinesKonstantin Ritt2015-02-061-0/+22
| | | | | | Change-Id: Ic19824e7e135f53a9ce3f2ea7ecd078a589e7425 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Introduce QQuaternion::inverted()Konstantin Ritt2015-01-281-0/+29
| | | | | Change-Id: I6de77082bb7c32e48fb7f7d765a58fdbe68db1fd Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Make gui/math3d classes use float rather than qrealSean Harmer2012-09-071-345/+338
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This corrects the mismatch between using floats for internal storage and qreal in the API of QVector*D which leads to lots of implicit casts between double and float. This change also stops users from being surprised by the loss of precision when using these classes on desktop platforms and removes the need for the private constructors taking a dummy int as the final argument. The QMatrix4x4 and QQuaternion classes have been changed to use float for their internal storage since these are meant to be used in conjunction with the QVector*D classes. This is to prevent unexpected loss of precision and to improve performance. The on-disk format has also been changed from double to float thereby reducing the storage required when streaming vectors and matrices. This is potentially a large saving when working with complex 3D meshes etc. This also has a significant performance improvement when passing matrices to QOpenGLShaderProgram (and QGLShaderProgram) as we no longer have to iterate and convert the data to floats. This is an operation that could easily be needed many times per frame. This change also opens the door for further optimisations of these classes to be implemented by using SIMD intrinsics. This needs to be applied in conjunction with https://codereview.qt-project.org/#change,33548 Task-number: QTBUG-21035 Task-number: QTBUG-20661 Change-Id: I9321b06040ffb93ae1cbd72fd2013267ac901b2e Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Do not consider sign in qIsNull.Mitch Curtis2012-08-221-0/+7
| | | | | | | | | | | | | | | The current implementation of qIsNull only returns true if the value is positive zero. This behaviour is not useful for use cases like QPointF::isNull, where QPointF(-0, -0).isNull() will return false. There doesn't seem to be a reason why the function exhibits this behaviour (-0.0 is not accounted for in the unit tests), and for the case of QSizeF::scale it causes a bug: qIsNull is used to check for division by 0.0 before it proceeds, which fails in the case of -0.0. Task-number: QTBUG-7303 Change-Id: I767e5280bd26614e8e78ae62b274eb9bc4ade385 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
* Don't use obsolete qVariantValue, qVariantCanConvert, etc.Debao Zhang2012-05-021-3/+3
| | | | | | | | | | qVariantValue and qVariantCanConvert are Compatibility members, while in Qt4.8 they are marked as Qt 3 Support Members. qVariantFromValue and qVariantSetValue are Obsolete members. Change-Id: Ie8505cad1e0950e40c6f6710fde9f6fb2ac670fd Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Moved gui autotests into new directory structureJo Asplin2011-09-011-0/+888
Task-number: QTBUG-21133 Change-Id: I83b8f652935cf92151265ca2530a3cf81c31fdef Reviewed-on: http://codereview.qt.nokia.com/3996 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jo Asplin <jo.asplin@nokia.com>