dijkstra is now bleching fast
deleting from the grid is now bleaching fast added new helper methods many new test-cases many new methods for geo classes and others added a bunch of new grid-walkers
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define HEADING_H
|
||||
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
|
||||
#include "Angle.h"
|
||||
|
||||
@@ -35,11 +36,16 @@ public:
|
||||
Heading& operator += (const float _rad) {
|
||||
_assertBetween(_rad, -_2PI*0.99, +_2PI*0.99, "radians out of bounds");
|
||||
rad += _rad;
|
||||
if (rad > _2PI) {rad -= _2PI;}
|
||||
if (rad < 0) {rad += _2PI;}
|
||||
if (rad >= _2PI) {rad -= _2PI;}
|
||||
else if (rad < 0) {rad += _2PI;}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** update the angle but ensure we stay within [0:2PI] */
|
||||
Heading operator + (const float _rad) const {
|
||||
return (Heading(*this) += _rad);
|
||||
}
|
||||
|
||||
/** get an inverted version of this heading (upwards -> downwards, left -> right, ...) */
|
||||
Heading getInverted() const {
|
||||
Heading out(rad);
|
||||
@@ -49,6 +55,13 @@ public:
|
||||
|
||||
float getRAD() const {return rad;}
|
||||
|
||||
/** get a random heading */
|
||||
static Heading rnd() {
|
||||
static std::minstd_rand gen; gen.seed(1234);
|
||||
static std::uniform_real_distribution<float> dist(0, _2PI);
|
||||
return Heading(dist(gen));
|
||||
}
|
||||
|
||||
#undef _2PI
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user