Optimization of Measuring Magnetic Fields for Position and Orientation Tracking