When I take the sin of something in C++ it returns the sin in rad. I want it in degree.
so is there a any other way other than taking rad * (180/pi) ?
Are you asking whether there is a function that can do that for you? After all, to convert radians to degrees
someone has to perform the calculation, and all the standard math functions in math.h work with radians. If you are writing Orbiter code you can just use the DEG constant defined in OrbiterAPI.h as follows:
Code:
double myDegrees = rad * DEG;
That's about as simple as it gets.
If you aren't writing Orbiter code you can just define your own DEG constant as follows and then use rad * DEG as shown above:
Code:
const double PI = 3.14159265358979;
const double DEG = 180.0/PI;
If you'd rather have an inline method to do the calculation, just add these lines to your class's header file:
Code:
const double PI = 3.14159265358979;
double ToDegrees(const double rad) { return rad * 180.0 / PI; }
...and then use it like this:
Code:
double myDegrees = ToDegrees(rad);
Personally I prefer just using the DEG constant as shown in the first example.