/// <summary> /// Smoothes the input value. /// </summary> /// <param name="value">Input value.</param> /// <returns>Returns the filtered value.</returns> public float Filter(float value) { UpdateSensorFrequency(); float dx = m_XFilter.GetIsInitialized() ? (value - m_XFilter.GetRawInput()) * m_SensorFrequency : 0f; float edx = m_DXFilter.UpdateFilterValue(dx, GetWeight(m_DerivateCutoffFrequency)); float cutoff = m_MinCutoff + (m_BetaCutoffSlope * Mathf.Abs(edx)); m_LastValue = m_XFilter.UpdateFilterValue(value, GetWeight(cutoff)); return(m_LastValue); }
/// <summary> /// Smoothes the input value. /// </summary> /// <param name="value">Input value.</param> /// <returns>Returns the filtered value.</returns> public float Filter(float value) { UpdateSensorFrequency(); float dx = _xFilter.GetIsInitialized() ? (value - _xFilter.GetRawInput()) * _sensorFrequency : 0f; float edx = _dxFilter.UpdateFilterValue(dx, GetWeight(_derivateCutoffFrequency)); float cutoff = _minCutoff + (_betaCutoffSlope * Mathf.Abs(edx)); _lastValue = _xFilter.UpdateFilterValue(value, GetWeight(cutoff)); return(_lastValue); }