I have an object with a position matrix and a rotation matrix (derived from a quaternion, but I digress). I'm able to translate this object along world-relative vectors, but I'm trying to figure out how to translate it along local-relative vectors. So if the object is tilted 45 degrees around its Z-axis the vector (1, 0, 0) would make it move to the upper right.
For world-space translations I simply turn the movement vector into a matrix and multiply it by the position matrix: position_mat = translation_mat * position_mat
. For local-space translations I'd think I'd have to use the rotation matrix into that formula, but I see the object spin around instead when I apply a translation over time no matter where I multiply the rotation matrix.
position_mat = (translation_mat * rotation_mat) * position_mat
. I've tried this already but, as I said before, the translation doesn't go in a straight line. So if my object is tilted to the left and I try to translate it to go towards its local left (upper-left in world space) over a period of time, the object spins around instead. – Aaron Jul 05 '12 at 23:08position_mat
, applying the rotation to the whole object instead of just the translation vector. And since you do this every frame, of course the object spins around over time. – Nathan Reed Jul 05 '12 at 23:11