kopia lustrzana https://github.com/xdsopl/robot36
added low pass filter
rodzic
5d92cb4b29
commit
9e84f1cd8f
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
FIR Filter
|
||||
|
||||
Copyright 2024 Ahmet Inan <xdsopl@gmail.com>
|
||||
*/
|
||||
|
||||
package xdsopl.robot36;
|
||||
|
||||
public final class Filter {
|
||||
public static double sinc(double x) {
|
||||
if (x == 0)
|
||||
return 1;
|
||||
x *= Math.PI;
|
||||
return Math.sin(x) / x;
|
||||
}
|
||||
|
||||
public static double lowPass(double cutoff, int n, int N) {
|
||||
double f = 2 * cutoff;
|
||||
double x = n - (N - 1) / 2.0;
|
||||
return f * sinc(f * x);
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue