19#define _USE_MATH_DEFINES
59 std::vector<int> *mapped_features)
const {
60 mapped_features->clear();
61 for (
int f = 0; f < num_features; ++f) {
62 mapped_features->push_back(
Index(features[f]));
69 std::vector<int> *sorted_features)
const {
70 sorted_features->clear();
71 for (
int f = 0; f < num_features; ++f) {
72 sorted_features->push_back(
Index(features[f]));
74 std::sort(sorted_features->begin(), sorted_features->end());
83 for (
int theta = 0; theta <= UINT8_MAX && index < 0; ++theta) {
84 feature.
Theta = theta;
85 index =
Index(feature);
88 tprintf(
"(%d,%d) does not exist in feature space!\n",
x,
y);
92 tprintf(
"Click at (%d, %d) ->(%d, %d), ->(%d, %d)\n",
x,
y, feature.
X, feature.
Y,
x - feature.
X,
97 if (
x != 0 ||
y != 0) {
98 double angle = atan2(
static_cast<double>(
y),
static_cast<double>(
x)) + M_PI;
100 feature.
Theta =
static_cast<uint8_t
>(angle + 0.5);
101 index =
Index(feature);
103 tprintf(
"Feature failed to map to a valid index:");
const int kIntFeatureExtent
void tprintf(const char *format,...)
int DivRounded(int a, int b)
void Init(uint8_t xbuckets, uint8_t ybuckets, uint8_t thetabuckets)
void IndexFeatures(const INT_FEATURE_STRUCT *features, int num_features, std::vector< int > *mapped_features) const
INT_FEATURE_STRUCT PositionFromIndex(int index) const
int Index(const INT_FEATURE_STRUCT &f) const
int XYToFeatureIndex(int x, int y) const
bool Serialize(FILE *fp) const
INT_FEATURE_STRUCT PositionFromBuckets(int x, int y, int theta) const
void IndexAndSortFeatures(const INT_FEATURE_STRUCT *features, int num_features, std::vector< int > *sorted_features) const