mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
added low pass filter
This commit is contained in:
parent
5d92cb4b29
commit
9e84f1cd8f
22
app/src/main/java/xdsopl/robot36/Filter.java
Normal file
22
app/src/main/java/xdsopl/robot36/Filter.java
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue