A computer-assisted surgery system comprises instruments adapted to be used to perform tasks related to surgery. A reference device is in a fixed relation to a bone. A rotating magnet creates a magnetic field plane, the rotating magnet being connected to one of the instrument and the reference device. A magnetometer on the other of the instrument and the reference device produces signals as a function of at least its orientation relative to the magnetic field plane. A processing unit tracks said orientation of the instrument relative to the bone using said signals from the magnetometer subjected to the magnetic field plane.