예제 #1
0
void tst_QQuaternion::rotationTo()
{
    QFETCH(QVector3D, from);
    QFETCH(QVector3D, to);

    QQuaternion q1 = QQuaternion::rotationTo(from, to);
    QVERIFY(myFuzzyCompare(q1, q1.normalized()));
    QVector3D vec1(q1 * from);
    vec1 *= (to.length() / from.length()); // discard rotated length
    QVERIFY(myFuzzyCompare(vec1, to));

    QQuaternion q2 = QQuaternion::rotationTo(to, from);
    QVERIFY(myFuzzyCompare(q2, q2.normalized()));
    QVector3D vec2(q2 * to);
    vec2 *= (from.length() / to.length()); // discard rotated length
    QVERIFY(myFuzzyCompare(vec2, from));
}
예제 #2
0
void tst_qquickcustomaffector::test_move()
{
    QQuickView* view = createView(testFileUrl("move.qml"), 600);
    QQuickParticleSystem* system = view->rootObject()->findChild<QQuickParticleSystem*>("system");
    ensureAnimTime(600, system->m_animation);

    QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
    for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
        if (d->t == -1)
            continue; //Particle data unused
        if (!d->stillAlive(system))
            continue; //parameters no longer get set once you die

        QVERIFY2(myFuzzyCompare(d->curX(system), 50.0), QByteArray::number(d->curX(system)));
        QVERIFY2(myFuzzyCompare(d->curY(system), 50.0), QByteArray::number(d->curY(system)));
        QVERIFY2(myFuzzyCompare(d->curVX(system), 50.0), QByteArray::number(d->curVX(system)));
        QVERIFY2(myFuzzyCompare(d->curVY(system), 50.0), QByteArray::number(d->curVY(system)));
        QVERIFY2(myFuzzyCompare(d->curAX(), 50.0), QByteArray::number(d->curAX()));
        QVERIFY2(myFuzzyCompare(d->curAY(), 50.0), QByteArray::number(d->curAY()));
        QCOMPARE(d->lifeSpan, 0.5f);
        QCOMPARE(d->size, 32.f);
        QCOMPARE(d->endSize, 32.f);
        QVERIFY2(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)),
                 QString::fromLatin1("%1 <= %2 / 1000").arg(d->t).arg(system->timeInt).toUtf8());
    }
    delete view;
}
예제 #3
0
void tst_QQuaternion::fromAxes()
{
    QFETCH(float, x1);
    QFETCH(float, y1);
    QFETCH(float, z1);
    QFETCH(float, angle);
    QFETCH(QVector3D, xAxis);
    QFETCH(QVector3D, yAxis);
    QFETCH(QVector3D, zAxis);

    QQuaternion result = QQuaternion::fromAxisAndAngle(QVector3D(x1, y1, z1), angle);

    QVector3D axes[3];
    result.getAxes(&axes[0], &axes[1], &axes[2]);
    QVERIFY(myFuzzyCompare(axes[0], xAxis));
    QVERIFY(myFuzzyCompare(axes[1], yAxis));
    QVERIFY(myFuzzyCompare(axes[2], zAxis));

    QQuaternion answer = QQuaternion::fromAxes(axes[0], axes[1], axes[2]);

    QVERIFY(qFuzzyCompare(answer, result) || qFuzzyCompare(-answer, result));
}
예제 #4
0
static inline bool myFuzzyCompare(const QQuaternion &q1, const QQuaternion &q2)
{
    const float d = QQuaternion::dotProduct(q1, q2);
    return myFuzzyCompare(d * d, 1.0f);
}
예제 #5
0
static inline bool myFuzzyCompare(const QVector3D &v1, const QVector3D &v2)
{
    return myFuzzyCompare(v1.x(), v2.x())
            && myFuzzyCompare(v1.y(), v2.y())
            && myFuzzyCompare(v1.z(), v2.z());
}