version using discrete values stored directly at intersection
This commit is contained in:
committed by
Patrick Niklaus
parent
ba074b0116
commit
0f3942558f
@@ -36,7 +36,7 @@ class BearingClass
|
||||
{
|
||||
public:
|
||||
using FlagBaseType = std::uint32_t;
|
||||
const static constexpr double discrete_angle_step_size = 360. / 24;
|
||||
const static constexpr double discrete_angle_step_size = 360. / 32;
|
||||
|
||||
BearingClass();
|
||||
|
||||
@@ -46,6 +46,14 @@ class BearingClass
|
||||
// add a discrete ID, returns true if no item existed that uses the same discrete angle
|
||||
bool addDiscreteID(const std::uint8_t id);
|
||||
|
||||
//remove a bearing from the list
|
||||
void resetContinuous(const double bearing);
|
||||
void resetDiscreteID(const std::uint8_t id);
|
||||
|
||||
//is available
|
||||
bool hasContinuous(const double bearing) const;
|
||||
bool hasDiscrete(const std::uint8_t id) const;
|
||||
|
||||
// hashing
|
||||
bool operator==(const BearingClass &other) const;
|
||||
|
||||
@@ -56,7 +64,8 @@ class BearingClass
|
||||
|
||||
// get a discrete representation of an angle. Required to map a bearing/angle to the discrete
|
||||
// ones stored within the class
|
||||
static std::uint8_t discreteBearingID(double angle);
|
||||
static std::uint8_t angleToDiscreteID(double angle);
|
||||
static double discreteIDToAngle( const std::uint8_t );
|
||||
|
||||
// we are hiding the access to the flags behind a protection wall, to make sure the bit logic
|
||||
// isn't tempered with
|
||||
|
||||
@@ -56,7 +56,7 @@ inline double getMatchingDiscreteBearing(const bool requires_entry,
|
||||
return 0;
|
||||
|
||||
const double discrete_bearing =
|
||||
BearingClass::discreteBearingID(bearing) * BearingClass::discrete_angle_step_size;
|
||||
BearingClass::discreteIDToAngle(BearingClass::angleToDiscreteID(bearing));
|
||||
// it they are very close to the turn, the discrete bearing should be fine
|
||||
if (std::abs(bearing - discrete_bearing) < 0.25 * BearingClass::discrete_angle_step_size)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user