void computeAverageQ ( Cache cache ) { float [ ] weights = cache . weights . data ; cache . aveQ . set ( 0 , 0 ) ; for ( int i = 0 ; i < controls . size ( ) ; i ++ ) { Control c = controls . get ( i ) ; float w = weights [ i ] ; cache . aveQ . x += c . q . x * w ; cache . aveQ . y += c . q . y * w ; } cache . aveQ . x /= cache . totalWeight ; cache . aveQ . y /= cache . totalWeight ; }
Computes the average Q given the weights at this cached point