* DataHistory::ValueAt() now interpolates between two values in case the time

doesn't match exactly one data item (before, it would have returned the
  value of the closest but earlier value).
* This almost removes the effect that the older values seem to change with
  every refresh (because the time did not always match exactly)).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26429 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-07-15 15:55:28 +00:00
parent fe71730a9c
commit 84e23a5d08

View File

@ -172,9 +172,14 @@ DataHistory::ValueAt(bigtime_t time)
// search in left part
right = index - 1;
} else {
if (index + 1 >= fBuffer.CountItems()
|| fBuffer.ItemAt(index + 1)->time > time) {
data_item* nextItem = fBuffer.ItemAt(index + 1);
if (nextItem == NULL)
return item->value;
if (nextItem->time > time) {
// found item
int64 value = item->value;
value += int64(double(nextItem->value - value)
/ (nextItem->time - item->time) * (time - item->time));
return item->value;
}