Go to the documentation of this file.
17 #ifndef IGNITION_MATH_FILTER_HH_
18 #define IGNITION_MATH_FILTER_HH_
23 #include <ignition/math/config.hh>
30 inline namespace IGNITION_MATH_VERSION_NAMESPACE {
42 public:
virtual void Set(
const T &_val)
50 public:
virtual void Fc(
double _fc,
double _fs) = 0;
54 public:
virtual const T &
Value()
const
81 public:
virtual void Fc(
double _fc,
double _fs)
override
83 b1 = exp(-2.0 *
IGN_PI * _fc / _fs);
92 this->y0 = a0 * _x + b1 * this->y0;
97 protected:
double a0 = 0;
100 protected:
double b1 = 0;
160 public:
BiQuad() =
default;
171 public:
void Fc(
double _fc,
double _fs)
override
173 this->Fc(_fc, _fs, 0.5);
180 public:
void Fc(
double _fc,
double _fs,
double _q)
182 double k = tan(
IGN_PI * _fc / _fs);
183 double kQuadDenom = k * k + k / _q + 1.0;
184 this->a0 = k * k/ kQuadDenom;
185 this->a1 = 2 * this->a0;
188 this->b1 = 2 * (k * k - 1.0) / kQuadDenom;
189 this->b2 = (k * k - k / _q + 1.0) / kQuadDenom;
194 public:
virtual void Set(
const T &_val)
override
196 this->y0 = this->y1 = this->y2 = this->x1 = this->x2 = _val;
204 this->y0 = this->a0 * _x +
205 this->a1 * this->x1 +
206 this->a2 * this->x2 -
207 this->b1 * this->y1 -
218 protected:
double a0 = 0,
226 protected: T x1{}, x2{}, y1{}, y2{};
OnePoleVector3(double _fc, double _fs)
Constructor.
Definition: Filter.hh:146
BiQuadVector3()
Constructor.
Definition: Filter.hh:234
OnePoleQuaternion(double _fc, double _fs)
Constructor.
Definition: Filter.hh:116
virtual ~Filter()
Destructor.
Definition: Filter.hh:38
Definition: AdditivelySeparableScalarField3.hh:27
T y0
Output.
Definition: Filter.hh:60
T y1
Definition: Filter.hh:226
A one-pole DSP filter.
Definition: Filter.hh:67
double a0
Input gain control.
Definition: Filter.hh:97
double a2
Definition: Filter.hh:220
virtual const T & Process(const T &_x)
Update the filter's output.
Definition: Filter.hh:202
BiQuadVector3(double _fc, double _fs)
Constructor.
Definition: Filter.hh:242
A quaternion class.
Definition: Matrix3.hh:35
T x2
Definition: Filter.hh:226
#define IGN_PI
Define IGN_PI, IGN_PI_2, and IGN_PI_4. This was put here for Windows support.
Definition: Helpers.hh:184
BiQuad()=default
Constructor.
One-pole quaternion filter.
Definition: Filter.hh:105
static Quaternion< T > Slerp(T _fT, const Quaternion< T > &_rkP, const Quaternion< T > &_rkQ, bool _shortestPath=false)
Spherical linear interpolation between 2 quaternions, given the ends and an interpolation parameter b...
Definition: Quaternion.hh:885
OnePole(double _fc, double _fs)
Constructor.
Definition: Filter.hh:75
virtual const T & Value() const
Get the output of the filter.
Definition: Filter.hh:54
double b1
Gain of the feedback.
Definition: Filter.hh:100
const T & Process(const T &_x)
Update the filter's output.
Definition: Filter.hh:90
OnePoleQuaternion()
Constructor.
Definition: Filter.hh:108
T y2
Definition: Filter.hh:226
double a1
Definition: Filter.hh:219
Bi-quad filter base class.
Definition: Filter.hh:157
virtual void Fc(double _fc, double _fs)=0
Set the cutoff frequency and sample rate.
void Fc(double _fc, double _fs, double _q)
Set the cutoff frequency, sample rate and Q coefficient.
Definition: Filter.hh:180
double b2
Definition: Filter.hh:223
Filter base class.
Definition: Filter.hh:35
OnePoleVector3()
Constructor.
Definition: Filter.hh:138
T x1
Gain of the feedback coefficients.
Definition: Filter.hh:226
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: Vector3.hh:41
const math::Quaterniond & Process(const math::Quaterniond &_x)
Update the filter's output.
Definition: Filter.hh:125
double b0
Definition: Filter.hh:221
BiQuad(double _fc, double _fs)
Constructor.
Definition: Filter.hh:165
void Fc(double _fc, double _fs) override
Set the cutoff frequency and sample rate.
Definition: Filter.hh:171
BiQuad vector3 filter.
Definition: Filter.hh:231
double b1
Definition: Filter.hh:222
virtual void Set(const T &_val) override
Set the current filter's output.
Definition: Filter.hh:194
virtual void Set(const T &_val)
Set the output of the filter.
Definition: Filter.hh:42
One-pole vector3 filter.
Definition: Filter.hh:135
OnePole()=default
Constructor.
virtual void Fc(double _fc, double _fs) override
Set the cutoff frequency and sample rate.
Definition: Filter.hh:81
double a0
Input gain control coefficients.
Definition: Filter.hh:218