interpolate between intervals

This commit is contained in:
Micho 2013-05-19 09:56:40 +02:00
parent bcb8daffcf
commit e55e17a762
1 changed files with 12 additions and 2 deletions

View File

@ -111,10 +111,20 @@ function updateData() {
}) })
data.matrix.forEach(function (times, index) { data.matrix.forEach(function (times, index) {
var timeId = time2index[Math.floor(currentTime + 15*random[index])]; var timeId = time2index[Math.floor(currentTime)];
var point = undefined; var point = undefined;
if (isFinite(times[timeId])) point = times[timeId];
var t0 = data.times[timeId]; if (isNaN(t0)) t0 = 0;
var t1 = data.times[timeId+1]; if (isNaN(t1)) t1 = 1e10;
var offset = (currentTime-t0)/(t1-t0);
if (offset < random[index]) {
point = times[timeId-1];
} else {
point = times[timeId];
}
var client = clients[index]; var client = clients[index];
if (client.point != point) { if (client.point != point) {