Design options for tracking relative orientation of two elements
The "passive" element can be printed with some sort of visual pattern. Think of a cube with each side painted a unique color.

A camera in the "active" element can determine both the distance (from the overall size of the image) and the orientation of the passive element with some moderately complex image processing.

But if the "active" element can also have any arbitrary orientation, it would need to have a camera on every face to insure that it always has the "passive" element in view.

You could definitely cram six cellphone cameras into a 1-inch cube, but the actual image processing would have to be done remotely, on something like a RPi or BBB.