On 8 January 2015 at 00:10, Tomaz Canabrava <[email protected]> wrote:
>>
>> 2) those extra 10% are caused by the new
>> InstantMeanDepthLine::mouseMoved()
>> as it calculates based on the running average each time instead of
>> using a lookup table.
>
>
> Hm... can you ( or anyone else ) help me to create a lookup table?
>

conceptually and untested, also not sure how well this will work in
the 'time' context.

in void InstantMeanDepthLine::mouseMoved(int time, int depth)
the following calculations can be LUT-ed (lookup table-ed):

// *
mean = pI.running_sum / time
x = hAxis->posAtValue(time)
y = vAxis->posAtValue(mean)

you would need a 3d array and populate that each time the model changes:

// populate the LUT
for (int i = 0; i < count; i++) {
   ...
   // *
   ...
   int idx = pI.sec / count;
   lut[idx][0] = mean;
   lut[idx][1] = x;
   lut[idx][2] = y;
}

// in mouseMoved(); for each 'time' get the LUT index
int idx =  time * count;

setMeanDepth(lut[idx][0]);
setLine(0, 0, lut[idx][1], 0);
setPos(pos().x(), lut[idx][2]);

needs error checking and possible rounding.
the idea is to retrieve the index of where the calculations for this
'time' are eventually stored.
the size of the LUT can potentially be less than 'count' which will
reduce the precision.

lubomir
--
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to