# How do I multiply a Vector3f with a Quaternion?

Hi,

How do I multiply a Vector3f with a Quaternion?

Ex. Vector3f translation; Quaternion quat;

Vector3f = translation.mult(quat); // I need sth. like that

There is quat.mult(Vector3f), but not vice versa (the

multiplication is not commutative).

Thanks,

Bernd

Don't think multiplying a vector3f with a quaternion means anything…

Quaternion.mult(vector3f) means rotate that vector using the quaternion. but the reverse is not really meaningful (I think)

Yes, you can use a quaternion to rotate a vector:

v' = q * v * q^-1

where v' is the rotated vector, q is the quaternion and v is the original vector.

This is usually done by converting the quaternion to a matrix and then doing the multiplication.

What is it you're trying to do?

>What is it you're trying to do?

I have some JME1 stuff that I want to convert to JME2:

camNode.getWorldTransform().transform(camPos); // JME1, result is in camPos

getWorldTransform() doesn't exist in JME2, so I tried sth. like that:

Vector3f camPos = camNode.getWorldRotation().mult(camNode.getWorldTranslation()); //JME2

// getScale is (1,1,1), so it's not in the equation.

That didn't give the results I had in JME1.

An extermal programmer thought it would be vice versa:

camPos = camNode.getWorldTranslation().mult(camNode.getWorldRotation),

where camNode.getWorldRotation() returns a Quaternion.

So that was my question.

Perhaps this is all wrong, what I'm doing, I'm not sure.

All I need is to convert that to JME2:

camNode.getWorldTransform().transform(camPos); // JME1

Any help is appreciated

I never used JME1, so I can only assume getWorldTransform returned a matrix right? Basically the world matrix, would can be computed as such: scalingMatrix x rotationMatrix x translationMatrix. You could, if you wanted to, just create the matrices from the world scale, rotation, and translation values. But if you just needed the world translation, and had unit scale then what Tumaini and bob said would be what you'd do to get the absolute world translation. I would look at Quaternion's vector3 mult method.

But I'm wondering are we to assume camPos is the world position of the camera? If you're using a camera node, then the world position of the camera would just be the world translation of the camera node.