I have a vec3 called delta that represents (in world coordinates) the amount by which an object's position should be moved in the X,Y and Z directions (in world coordinates).
But sometimes I want to apply just the X delta for instance (i.e. I want to discard the Y and Z components) moving the object by X delta along the object's X-axis so that when the delta is applied it effectively moves the object in the world but along the direction of the object's X-axis (if that makes sense).
I tried doing this by (given an object with a 4x4 local to world matrix):
a) Multiply vec3(1.f, 0.f, 0.f) (i.e. the object's X-axis in its local coord system) by the object's local to world matrix, i.e. translate the object's x-axis into the world coord system
b) Multiply the vec3 delta by the transformed x-axis vector from step (a) in the hope of adjusting the delta so it only applies the X component
c) Apply the X delta from step (b) to the object's position
This doesn't work so clearly I'm confused about something, I think step a) is wrong so instead for step a):
If I have the object's local to world transform components stored separately i.e. scale, orientation (quaternion) and position then I think I can generate a 3x3 rotation matrix from the orientation quaternion that will give me the object's basis vectors (i.e. the X, Y and Z axis) expressed in world coordinates un-scaled and un-translated? If so I can then do steps b and c with the X basis vector to mask off (remove) the Y and Z components.
Is this correct?
Thanks in advance for any help.