A method, including receiving from a sensor affixed to a probe, signals output by the sensor in response to a calibrated magnetic field, and estimating, using calibration data, location coordinates of the sensor. Using the calibration data and the estimated location, an estimated vector including orientation coordinates is computed, and updated orientation coordinates that best fit the received signals to the estimated vector are computed for the estimated location. Based on the updated orientation, updated location coordinates that best fit the received signals to the estimated vector are computed. The steps of computing the vector, computing the orientation, and computing the location and monitoring changes in the updated location are repeated until the changes are linear. Upon the changes being linear, a final location of the sensor is computed using a linear projection from the updated location, and a position of the probe is presented based on the final location.