H
H
hhrhhr2011-07-09 15:45:20
Java
hhrhhr, 2011-07-09 15:45:20

Rotation Matrices, Java -> QT4?

Please tell me how to re-format the Java code into the corresponding operations in QT4.
here it is in Java:

Vector4f up = new Vector4f(0,1,0,0);
Matrix4f modelToWorld = new Matrix4f();
// skipped
modelToWorld.invert();
modelToWorld.transform(up)
// ля-ля-ля

started in QT4:
QVector4D up = QVector4D(1,0,0,0);
QMatrix4x4 modelToWorld = new QMatrix4x4();
// skipped
modelToWorld = modelToWorld.inverted();
// ???

in fact, the code must rotate the vector in a certain way, but I would like the entire matrix to rotate in the same way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Utkin, 2014-05-20
@hhrhhr

The * operator is redefined as not a member of the class and returns the result of the transformation:

QVector4D operator*( const QMatrix4x4& matrix, const QVector4D& vector )
// Можно поменять местами
QVector4D operator*( const QVector4D& vector, const QMatrix4x4& matrix )

The result is a 4D vector.
QVector4D result = modelToWorld * up;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question