forked from LupusNobilis/java-org.hwo
FastSmoother hinzugefügt
parent
0772048927
commit
17fa3cbe0f
|
@ -0,0 +1,37 @@
|
||||||
|
package org.hwo;
|
||||||
|
|
||||||
|
public class FastSmoother {
|
||||||
|
|
||||||
|
private float tn;
|
||||||
|
private float sum;
|
||||||
|
private float value;
|
||||||
|
|
||||||
|
public FastSmoother(float tn){
|
||||||
|
this.sum = 0;
|
||||||
|
this.tn = tn;
|
||||||
|
this.value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float smooth(float sample){
|
||||||
|
this.sum += sample;
|
||||||
|
this.value = this.sum / this.tn;
|
||||||
|
this.sum -= this.value;
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getSum() {
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
public void setSum(float sum) {
|
||||||
|
this.sum = sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(float value) {
|
||||||
|
this.value = value;
|
||||||
|
this.sum = (value * this.tn) - value;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue