Translating an object based on a rotation

Started by DaveAnd, May 04, 2013, 09:48:02 PM

Previous topic - Next topic

DaveAnd

Hi - I have been wresting with rotating an object and then translating it along that rotated axis but with no joy. I have searched for this but havent found actual code.

So what I would really like is code to give an angle of rotation and then translate according to that rotation.

Cool project btw :)

Dave

Thomas.

You can use something like...

SimpleVector vector = SimpleVector.create();
object.getRotationMatrix().getZAxis(vector);
vector.scalarMul(10);
object.translate(vector);

DaveAnd

does that specify the angle of rotation or translation? am looking for a way to do one followed by the other (with the translation following the resulting rotated axis)

Thanks!

Thomas.

The attribute in method vector.scalarMul(10) is how large move of object will be.

DaveAnd

ok so would you need to rotate before this code?

Thomas.

You can use this code anywhere, before, after rotation, it does not matter. This is useful ex. for car. You may rotate with car, but car will go always forward.