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:
2016-01-26 18:13:30 +01:00
parent b503fb9bdc
commit e6329e1db4
26 changed files with 824 additions and 179 deletions

View File

@@ -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
};