summaryrefslogtreecommitdiffhomepage
path: root/filter-accela
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-20 07:30:21 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-20 07:30:21 +0200
commit8cf0cb5811bf5a9461f3455e5fd0195f5ef3d287 (patch)
tree0a0e41cbc8277dd7df89ab14b9557ef59cb8975b /filter-accela
parent1efc28c75b80b8129b90c3d5f0bb64068ef642ef (diff)
filter/accela: make more readable
progn is similar to one in CLHS cf. http://clhs.lisp.se/Body/s_progn.htm
Diffstat (limited to 'filter-accela')
-rw-r--r--filter-accela/ftnoir_filter_accela.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp
index 697f6d8b..c0f355a4 100644
--- a/filter-accela/ftnoir_filter_accela.cpp
+++ b/filter-accela/ftnoir_filter_accela.cpp
@@ -61,9 +61,17 @@ void FTNoIR_Filter::filter(const double* input, double *output)
const double vec_ = std::max(0., fabs(vec) - dz);
const double thres = i >= 3 ? rot_t : trans_t;
const double out_ = vec_ / thres;
- const double out = i >= 3 && std::fabs(rot_nl - 1) > 5e-3 && vec_ < rot_nl_.max()
- ? (std::pow(out_/rot_nl_.max(), rot_nl))
- : out_;
+ const double out = progn(
+ const bool should_apply_rot_nonlinearity =
+ i >= 3 &&
+ std::fabs(rot_nl - 1) > 5e-3 &&
+ vec_ < rot_nl_.max();
+
+ if (should_apply_rot_nonlinearity)
+ return std::pow(out_/rot_nl_.max(), rot_nl);
+ else
+ return out_;
+ );
const double val = double(m.getValue(out));
last_output[i] = output[i] = last_output[i] + signum(vec) * dt * val;
}