Distance measurements using linear sensors reach their limits if the path length is too long and a large temperature range is required (temperature changes cause a change in the magnetic field strength of a magnet). If, instead of measuring only one component of the magnetic field, at least two components are measured in space, the angle of the magnetic field lines can be determined. By selecting a suitable magnet size, it is possible to achieve a sufficiently large change in angle over the measurement distance and thus high measurement accuracy. In addition, the shape of the field lines (and therefore the angle in the angle measurement) is independent of the magnet temperature, in contrast to the magnitude of the magnetic field strength, which makes temperature compensation of the magnetic field strength unnecessary. With sensors that perform differential angle measurement, external interference fields can be eliminated, which further increases the measurement accuracy.