17 #ifndef GZ_MATH_FILTER_HH_
18 #define GZ_MATH_FILTER_HH_
23 #include <gz/math/config.hh>
28 inline namespace GZ_MATH_VERSION_NAMESPACE {
40 public:
virtual void Set(
const T &_val)
48 public:
virtual void Fc(
double _fc,
double _fs) = 0;
52 public:
virtual const T &
Value()
const
79 public:
virtual void Fc(
double _fc,
double _fs)
override
81 b1 = exp(-2.0 *
GZ_PI * _fc / _fs);
90 this->y0 = a0 * _x + b1 * this->y0;
95 protected:
double a0 = 0;
98 protected:
double b1 = 0;
169 public:
void Fc(
double _fc,
double _fs)
override
171 this->Fc(_fc, _fs, 0.5);
178 public:
void Fc(
double _fc,
double _fs,
double _q)
180 double k = tan(
GZ_PI * _fc / _fs);
181 double kQuadDenom = k * k + k / _q + 1.0;
182 this->a0 = k * k/ kQuadDenom;
183 this->a1 = 2 * this->a0;
186 this->b1 = 2 * (k * k - 1.0) / kQuadDenom;
187 this->b2 = (k * k - k / _q + 1.0) / kQuadDenom;
192 public:
virtual void Set(
const T &_val)
override
194 this->y0 = this->y1 = this->y2 = this->x1 = this->x2 = _val;
202 this->y0 = this->a0 * _x +
203 this->a1 * this->x1 +
204 this->a2 * this->x2 -
205 this->b1 * this->y1 -
216 protected:
double a0 = 0,
224 protected: T x1{}, x2{}, y1{}, y2{};