19 void PhysxLinearInterpolationValues::
28 void PhysxLinearInterpolationValues::
29 insert(
float index,
float value) {
35 _min = std::min(_min, index);
36 _max = std::max(_max, index);
44 bool PhysxLinearInterpolationValues::
45 is_valid(
float number)
const {
47 return (number >= _min) && (number <= _max);
53 unsigned int PhysxLinearInterpolationValues::
62 float PhysxLinearInterpolationValues::
63 get_value(
float number)
const {
65 MapType::const_iterator lower = _map.begin();
70 MapType::const_iterator upper = _map.end();
76 upper = _map.lower_bound(number);
84 float w1 = number - lower->first;
85 float w2 = upper->first - number;
87 return ((w2 * lower->second) + (w1 * upper->second)) / (w1 + w2);
93 float PhysxLinearInterpolationValues::
94 get_value_at_index(
int index)
const {
96 MapType::const_iterator it = _map.begin();
98 for (
int i=0; i<index; i++) {
108 void PhysxLinearInterpolationValues::
109 output(std::ostream &out)
const {
111 MapType::const_iterator it = _map.begin();
113 for (; it != _map.end(); ++it) {
114 std::cout << it->first <<
" -> " << it->second <<
"\n";
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.