A method, including receiving from a sensor affixed to a probe,signals output by the sensor in response to a calibrated magneticfield, and estimating, using calibration data, locationcoordinates of the sensor. Using the calibration data and theestimated location, an estimated vector including orientationcoordinates is computed, and updated orientation coordinates thatbest fit the received signals to the estimated vector are computedfor the estimated location. Based on the updated orientation,updated location coordinates that best fit the received signals tothe estimated vector are computed. The steps of computing thevector, computing the orientation, and computing the location andmonitoring changes in the updated location are repeated until thechanges are linear. Upon the changes being linear, a finallocation of the sensor is computed using a linear projection fromthe updated location, and a position of the probe is presentedbased on the final location.