A method and device for tracking a position of an object includes using a field sensor (52) associated with the object to measure field strengths of magnetic fields generated by two or more field generators (42), wherein a measurement of at least one of the field strengths is subject to a distortion. Rotation-invariant location coordinates of the object are calculated responsively to the measured field strengths. Corrected location coordinates of the object are determined by applying to the rotation-invariant location coordinates a coordinate correcting function so as to adjust a relative contribution of each of the measured field strengths to the corrected location coordinates responsively to the distortion in the measured field strengths.