I'll usually just have a constant variable called "toRadians" = Pi / 180.0 and another called "toDegrees" = 180.0 / Pi. Wouldn't even need a function call.
Then you can easily do cos(45*toRadians);
I can only visualize a small set of angles, and those I already know their sin or cos, so I hate when applications ask me for degrees, that they will convert to radians, and compute their sin and cos to make a rotation.
¿where did you get `Pi'? ...so I hate when applications ask me for degrees
Yeah I just defined it myself, didn't mean to cause confusion.
The first thing that comes to my mind is an art program like photoshop or paint, much easier to ask the user for a degree than radian. I'm sure some programs let you specify if the user wants to use radians or degrees, of course.
1) If you already using Boost, you can get Pi as boost::math::constants::pi<double>();
2) If you do not use boost, it is often better to define it yourself:
1 2 3
constdouble Pi = 3.14159265358979323846264; //constant expression
constdouble Pi = std::atan2(0, -1); //Calculated in runtime
constdouble Pi = std::acos(-1);
> an art program like photoshop or paint, much easier to ask the user for a degree than radian.
¿In what operation? I can't seem to picture a case where I would want a box to write 42 degrees.
Would rather move a point, slide a bar, or pick an already done slope.
And in technical drawing, those weird angle measures would be calculated from other dimensions.
And for well know angles, 1/6, 1/4, 1/3 (pi implicit) are a lot more clear than 30, 45, 60.