MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / get

Method get

libraries/DistanceTable/DistanceTable.cpp:73–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72
73float 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

Callers 1

unittestFunction · 0.45

Calls

no outgoing calls

Tested by 1

unittestFunction · 0.36