new test cases
worked on all walkers new helper methods new distributions some bugfixes
This commit is contained in:
18
geo/Angle.h
18
geo/Angle.h
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <cmath>
|
||||
#include "../Assertions.h"
|
||||
#include "Point2.h"
|
||||
|
||||
struct Angle {
|
||||
|
||||
@@ -16,11 +17,17 @@ public:
|
||||
return (tmp < 0) ? (tmp + 2*M_PI) : (tmp);
|
||||
}
|
||||
|
||||
/** get the radians from (0,0) to (p.x,p.y) between 0 (to-the-right) and <2_PI */
|
||||
static float getRAD_2PI(const Point2& p) {
|
||||
return getRAD_2PI(0, 0, p.x, p.y);
|
||||
}
|
||||
|
||||
/** get the degrees from (x1,y1) to (x2,y2) between 0 (to-the-right) and <360 */
|
||||
static float getDEG_360(const float x1, const float y1, const float x2, const float y2) {
|
||||
return radToDeg(getRAD_2PI(x1,y1,x2,y2));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gets the angular difference between
|
||||
* - the given radians [0:2PI]
|
||||
@@ -35,12 +42,19 @@ public:
|
||||
|
||||
/** convert degrees to radians */
|
||||
static constexpr float degToRad(const float deg) {
|
||||
return deg / 180 * M_PI;
|
||||
return deg / 180.0f * M_PI;
|
||||
}
|
||||
|
||||
/** convert radians to degrees */
|
||||
static float radToDeg(const float rad) {
|
||||
return rad * 180 / M_PI;
|
||||
return rad * 180.0f / M_PI;
|
||||
}
|
||||
|
||||
/** get a pointer vector (length 1) pointing to the given angle (in radians) */
|
||||
static Point2 getPointer(const float rad) {
|
||||
const float x = cos(rad);
|
||||
const float y = sin(rad);
|
||||
return Point2(x,y);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user