| 71 | |
| 72 | |
| 73 | float DistanceTable::get (uint8_t x, uint8_t y) |
| 74 | { |
| 75 | // comment next line to skip range check (squeeze performance) |
| 76 | if ( (x >= _dimension) || (y >= _dimension)) return -1; // NAN ? |
| 77 | if ( x == y ) return 0.0; |
| 78 | |
| 79 | bool flag = false; |
| 80 | if ( x < y ) |
| 81 | { |
| 82 | uint8_t t = x; x = y; y = t; |
| 83 | flag = true; |
| 84 | } |
| 85 | uint16_t index = x; |
| 86 | index = (index * (index-1))/2 + y; |
| 87 | float value = _distanceTable[index]; |
| 88 | if (_invert && flag) value = -value; |
| 89 | return value; |
| 90 | }; |
| 91 | |
| 92 | |
| 93 | // triangular dump |