/// <summary> /// Smoothes data over multiple frames ( see Leap_SmoothingWindowSize ) /// The data is identified with the SmoothedValues indices /// </summary> /// <param name="id">Identifier for the data</param> /// <param name="newvalue">some new data that should be added to the calculation</param> /// <returns>the average value</returns> private float GetSmoothedValue(SmoothedValues id, float newvalue) { if (CoreSettings.CoreSettings.Default.Leap_SmoothingWindowSize == 0) { return(newvalue); } List <float> list; if (_valueHistory[(int)id] == null) { //initialize it list = _valueHistory[(int)id] = new List <float>(); } else { list = _valueHistory[(int)id]; } while (list.Count >= CoreSettings.CoreSettings.Default.Leap_SmoothingWindowSize) { list.RemoveAt(0); } list.Add(newvalue); float average = list.Average(); return(average); }
/// <summary> /// Get the smoothed value for a set of data /// </summary> /// <param name="id">Identifier for the data</param> /// <returns>the average value</returns> private float GetSmoothedValue(SmoothedValues id) { float average = 0.0f; if (_valueHistory[(int)id] != null) { average = _valueHistory[(int)id].Average(); } return(average); }
/// <summary> /// Get the smoothed value for a set of data /// </summary> /// <param name="id">Identifier for the data</param> /// <returns>the average value</returns> private float GetSmoothedValue(SmoothedValues id) { float average = 0.0f; if (_valueHistory[(int)id] != null) { average = _valueHistory[(int)id].Average(); } return average; }
/// <summary> /// Smoothes data over multiple frames ( see Leap_SmoothingWindowSize ) /// The data is identified with the SmoothedValues indices /// </summary> /// <param name="id">Identifier for the data</param> /// <param name="newvalue">some new data that should be added to the calculation</param> /// <returns>the average value</returns> private float GetSmoothedValue(SmoothedValues id, float newvalue) { if (CoreSettings.CoreSettings.Default.Leap_SmoothingWindowSize == 0) { return newvalue; } List<float> list; if (_valueHistory[(int)id] == null) { //initialize it list = _valueHistory[(int)id] = new List<float>(); } else { list = _valueHistory[(int)id]; } while(list.Count >= CoreSettings.CoreSettings.Default.Leap_SmoothingWindowSize) { list.RemoveAt(0); } list.Add(newvalue); float average = list.Average(); return average; }