I am working in a 3D engine integrating a physics library. The physics library uses a world coordinates which are located in the center of the object. The object for the sake of this example, is a $8 \times 8 \times 8$ unit cube. I need to convert this origin (vector 3) into local coordinates, so that I can have the bottom of the cube (bottom center) as reference/origin rather than the middle of the cube, regardless of the yaw pitch or roll.
So far what I have done which seem to work in most simple rotation cases is to take:
vec a = (0, 0, zradius/2)
//move the cube in the direction I want to achieve in local space (down).
a rotation_around_y(roll)
a rotation_around_x(pitch)
a rotation_around_z(yaw)
//create the rotation
a = origin of object
//then translate the object to the correct spot in space.
I do this and everything seems to work in most cases, save when rotating in odd number of ways (like along multiple axis). I was reading on the web that you should use matrices but i'm not positive how or in what order to use them.
Orange box is where the model should be and the cube model represents where it is currently drawing, and the purple flair represents the objects origin position.



