QMatrix4x4 rotate

Hi,
i want to use the rotate function from the QMatrix4x4 class. But i don't get the right QVector3D:
QMatrix4x4 rot; rot.setToIdentity(); rot.rotate(45, QVector3D(0, 0, 1)); // create rotation matrix with 45° and rotation vector in positive zdirection QVector3D test = QVector3D(1, 0, 0) * rot; //calculate the rotated vector qDebug() << test; // QVector3D(0.70710678118, 0.70710678118, 0)
The calculated vector should be QVector(0.70710678118, +0.70710678118, 0). Like here: http://www.nh.cas.cz/people/lazar/celler/online_tools.php?start_vec=1,0,0&rot_ax=0,0,1&rot_ang=45
Is this a bug or do i forget something?

I'm not very familiar with this class, but usually the matrix is multiplied to the leftof the vector. (Mv is not the same as vM)
Try:
QVector3D test = rot * QVector3D(1, 0, 0); //calculate the rotated vector

Oh thanks! Yeah that was my fault!

You should mark this as solved :)

Just for completeness, you can multiply the vector from the right side too, but you have to transpose the matrix (it's a unitary one) beforehand to obtain a correct result. And as a general side note, I'd advise just to use
QTransform
instead.

Good comment.
Further clarification; the inverse of a rotational matrix is always its transposition. This is useful :)