function
MathUtilities.expo
Blend a linear and a cubic response curve
The PX4 stick expo curve, math::expo in
src/lib/mathlib/math/Functions.hpp. It is odd, monotone for
every admissible fraction, fixes the endpoints at
+/-1, and softens the slope around center to
1 - fraction.
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | value | Real | | Normalized input, nominally in [-1, 1] |
| input | fraction | Real | | Cubic fraction, in [0, 1]; 0 is linear |
| output | result | Real | | Shaped output, +/-1 at +/-1 input |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function expo "Blend a linear and a cubic response curve"
input Real value "Normalized input, nominally in [-1, 1]";
input Real fraction "Cubic fraction, in [0, 1]; 0 is linear";
output Real result "Shaped output, +/-1 at +/-1 input";
protected
Real clipped;
Real blend;
algorithm
clipped := MathUtilities.clip(value, -1.0, 1.0);
blend := MathUtilities.clip(fraction, 0.0, 1.0);
result := (1.0 - blend) * clipped + blend * clipped ^ 3;
annotation(
Inline = true,
Documentation(info = "<html>
<p>The PX4 stick expo curve, <code>math::expo</code> in
<code>src/lib/mathlib/math/Functions.hpp</code>. It is odd, monotone for
every admissible <code>fraction</code>, fixes the endpoints at
<code>+/-1</code>, and softens the slope around center to
<code>1 - fraction</code>.</p>
</html>"));
end expo;