15 #include "physxLinearInterpolationValues.h"
22 void PhysxLinearInterpolationValues::
33 void PhysxLinearInterpolationValues::
34 insert(
float index,
float value) {
40 _min = min(_min, index);
41 _max = max(_max, index);
51 bool PhysxLinearInterpolationValues::
52 is_valid(
float number)
const {
54 return (number >= _min) && (number <= _max);
62 unsigned int PhysxLinearInterpolationValues::
73 float PhysxLinearInterpolationValues::
74 get_value(
float number)
const {
76 MapType::const_iterator lower = _map.begin();
81 MapType::const_iterator upper = _map.end();
87 upper = _map.lower_bound(number);
95 float w1 = number - lower->first;
96 float w2 = upper->first - number;
98 return ((w2 * lower->second) + (w1 * upper->second)) / (w1 + w2);
106 float PhysxLinearInterpolationValues::
107 get_value_at_index(
int index)
const {
109 MapType::const_iterator it = _map.begin();
111 for (
int i=0; i<index; i++) {
123 void PhysxLinearInterpolationValues::
124 output(ostream &out)
const {
126 MapType::const_iterator it = _map.begin();
128 for (; it != _map.end(); ++it) {
129 cout << it->first <<
" -> " << it->second <<
"\n";