I have a triple-axis magnetometer and a magnet, and I am trying to calculate the relative position of the magnet from the magnetometer.
The magnetometer outputs the strength of any fields detected in each of the (X,Y,Z) directions, and I understand that I'll have to compensate for the Earth's own field, as well as how to determine the relative location of the magnet, but what I do not understand is how to determine the distance that the magnet is from the magnetometer.
So my question is: assuming that I have a magnetometer pointed exactly straight towards a magnet, and the magnetometer is outputting the field strength, is there an equation that I can use to determine the distance that they are apart?
I have attempted doing some research into this, but all the results I am finding vary from one another incredibly. Any help/advice would be much appreciated.
Edit 1: I feel like I should note that I'm using a cylindrical magnet. Would the calculations be different if I were to use a rectangular one?