to get the spherical coordinates (theta, phi and alpha) i use this code:
double phi_rad = atan2f(z,sqrt((x*x)+(y*y)));
double theta_rad = atan2f(y, x);
double r = sqrt((x*x)+(y*y)+(z*z));
And to map theta to 0-360 degrees i use this code:
double theta_deg = (theta_rad/M_PI*180) + (theta_rad > 0 ? 0 : 360);
But how can i map phi to 0-360 degrees? I tryed the same principle as i used for theta_deg but it dont work really fine.
If phi is your azimuthal angle (0 to 2π) and theta is your polar angle (0 to π), you can do:
Then you can just convert from radians to degrees using the standard: