1
0
Fork 0

- lowpass: work with delta-sec = nil

- cosmetics
This commit is contained in:
mfranz 2008-04-23 22:01:44 +00:00
parent fe5c2ebb65
commit c78327ee21

View file

@ -328,7 +328,7 @@ var lowpass = {
me.value = v; me.value = v;
}, },
_filter_ : func(v) { _filter_ : func(v) {
var dt = getprop("/sim/time/delta-sec"); var dt = getprop("/sim/time/delta-sec") or 0;
var c = dt / (me.coeff + dt); var c = dt / (me.coeff + dt);
me.value = v * c + me.value * (1 - c); me.value = v * c + me.value * (1 - c);
}, },
@ -345,12 +345,12 @@ var angular_lowpass = {
var m = { parents : [angular_lowpass] }; var m = { parents : [angular_lowpass] };
m.sin = lowpass.new(coeff); m.sin = lowpass.new(coeff);
m.cos = lowpass.new(coeff); m.cos = lowpass.new(coeff);
m.buf = nil; m.value = nil;
return m; return m;
}, },
filter : func(v) { filter : func(v) {
v *= D2R; v *= D2R;
me.buf = math.atan2(me.sin.filter(math.sin(v)), me.cos.filter(math.cos(v))) * R2D; me.value = math.atan2(me.sin.filter(math.sin(v)), me.cos.filter(math.cos(v))) * R2D;
}, },
set : func(v) { set : func(v) {
v *= D2R; v *= D2R;
@ -358,7 +358,7 @@ var angular_lowpass = {
me.cos.set(math.cos(v)); me.cos.set(math.cos(v));
}, },
get : func { get : func {
me.buf; me.value;
}, },
}; };