yash101
19-02-2014, 21:07
Since I have started vision processing, these are nifty functions, that I've consicified into a single line so they are out of the way of your real code!
//string funcs, requiring string and sstream
string bool2str(bool in) { stringstream str; str << in; return str.str(); }
string int2str(int inp) { stringstream str; str << inp; return str.str(); }
string double2str(double in) { stringstream str; str << in; return str.str(); }
//math functions!
double tanDeg(double input) { return tan((input) * pi / 180); }
double hypotenuse(double legA, double legB) { return sqrt(((legA*legA) + (legB*legB))); }
double leg(double hypotenuse, double leg) { return sqrt(((hypotenuse*hypotenuse) - (leg*leg))); }
Give me any feedback and post more of these single-liner c functions!
//string funcs, requiring string and sstream
string bool2str(bool in) { stringstream str; str << in; return str.str(); }
string int2str(int inp) { stringstream str; str << inp; return str.str(); }
string double2str(double in) { stringstream str; str << in; return str.str(); }
//math functions!
double tanDeg(double input) { return tan((input) * pi / 180); }
double hypotenuse(double legA, double legB) { return sqrt(((legA*legA) + (legB*legB))); }
double leg(double hypotenuse, double leg) { return sqrt(((hypotenuse*hypotenuse) - (leg*leg))); }
Give me any feedback and post more of these single-liner c functions!