@BastiKay
What do you think about this solution ?
#include <hmc.h>
void setup()
{
double x, y, z, degree;
}
void loop()
{
delay(1000); // There will be new values every 100ms
HMC.getValues(&x,&y,&z);
//x = -298;
//y = 143;
degree = ((-180) * atan(y/x))/ 3,14159265;
if ((x > 0) and (y > 0)) degree = degree + 0; / 1. Quadrant
if ((x < 0) and (y > 0)) degree = degree + 180; / 2. Quadrant
if ((x < 0) and (y < 0)) degree = degree + 180; / 3. Quadrant
if ((x > 0) and (y < 0)) degree = 360 + degree; / 4. Quadrant
if ((x > 0) and (y == 0)) degree = 0;
if ((x == 0) and (y > 0)) degree = 90;
if ((x < 0) and ((y == 0) degree = 180;
if ((x == 0) and (y < 0)) degree = 270;
Serial.print(degree);
Serial.print(" :<-degree");
Serial.print("x:");
Serial.print(x);
Serial.print(" y:");
Serial.print(y);
Serial.print(" z:");
Serial.println(z);
}