diff options
author | André Nusser <andre.nusser@googlemail.com> | 2020-04-25 16:22:50 +0200 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2020-04-25 16:23:08 +0200 |
commit | 642ccefe86f51248b192e086a61ca665bbca3cfc (patch) | |
tree | 8e389d82bdb38e1088128e8acc546338642a96d3 | |
parent | c637d8630e6843c4677193da1ec5b2d7a60b6f07 (diff) |
Avoid jumps of the function for avoiding monotonicity.
-rw-r--r-- | src/powermap.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/powermap.cc b/src/powermap.cc index e2d1bef..dff604f 100644 --- a/src/powermap.cc +++ b/src/powermap.cc @@ -208,10 +208,20 @@ void Powermap::updateSpline() } else { auto const a2b2 = alpha*alpha + beta*beta; - if (a2b2 > 9) { + + // hard change to enforce monotonicity + // if (a2b2 > 9) { + // auto const tau = 3./sqrt(a2b2); + // m[i] = tau*alpha*deltas[i]; + // m[i+1] = tau*alpha*deltas[i]; + // } + + // soft change to enforce monotonicity + if (a2b2 >= 4.5) { + auto const l = std::min(1., (a2b2-4.5)/4.5); auto const tau = 3./sqrt(a2b2); - m[i] = tau*alpha*deltas[i]; - m[i+1] = tau*alpha*deltas[i]; + m[i] = (1-l)*m[i] + l*tau*alpha*deltas[i]; + m[i+1] = (1-l)*m[i+1] + l*tau*alpha*deltas[i]; } } } |