Floating magnets to sense magnetic fields

We've all seen a traditional compass. A ferromagnetic, magnetized needle is mounted on a rotating bearing (or floated on the surface of a liquid) so that it can rotate in the \(x-y\) plane. If there is an in-plane magnetic field \(\mathbf{B}\), the needle will rotate to align with that component of the field. (It stops in the aligned state because of friction; otherwise it would "librate",…