34 lines
722 B
C++
Executable File
34 lines
722 B
C++
Executable File
#ifndef ANGLE_H
|
|
#define ANGLE_H
|
|
|
|
#include <cmath>
|
|
|
|
class Angle {
|
|
|
|
public:
|
|
|
|
/** get the radians from (x1,y1) to (x2,y2) */
|
|
static float getRAD(const float x1, const float y1, const float x2, const float y2) {
|
|
const float tmp = std::atan2(y2-y1, x2-x1);
|
|
return (tmp < 0) ? (tmp + 2*M_PI) : (tmp);
|
|
}
|
|
|
|
/** get the degrees from (x1,y1) to (x2,y2) */
|
|
static float getDEG(const float x1, const float y1, const float x2, const float y2) {
|
|
return radToDeg(getRAD(x1,y1,x2,y2));
|
|
}
|
|
|
|
/** convert degrees to radians */
|
|
static float degToRad(const float deg) {
|
|
return deg / 180 * M_PI;
|
|
}
|
|
|
|
/** convert radians to degrees */
|
|
static float radToDeg(const float rad) {
|
|
return rad * 180 / M_PI;
|
|
}
|
|
|
|
};
|
|
|
|
#endif // ANGLE_H
|