fix_offset_3d function

Estimate the offset in each axis