I want to calculate a compass heading from a 5883 magnetometer sensor, using x and y readings.
To get the heading angle in degrees within a quadrant of 90 degrees I was thinking of:
arctan (x/y) (x and y being the magnetometers readings).
This gives me an angle within a 90 degree quadrant of 360 degrees, from this I can work out which quadrant the heading is in by looking at the + and - of the x and y values. and doing some simple maths subtracting 90,180 or 270 degrees to get the heading.
Does this seem like a sensible approach.
To get the heading angle in degrees within a quadrant of 90 degrees I was thinking of:
arctan (x/y) (x and y being the magnetometers readings).
This gives me an angle within a 90 degree quadrant of 360 degrees, from this I can work out which quadrant the heading is in by looking at the + and - of the x and y values. and doing some simple maths subtracting 90,180 or 270 degrees to get the heading.
Does this seem like a sensible approach.