Simultaneous electromagnetic tracking and calibration for dynamic field distortion compensation