boundControl
timed_float TPT.boundControl(timed_float expr, timed_float min, timed_float max, [int options])
This function checks if the time dependent expression expr(t) is out of the limits [min, max] within the current context interval. The result is for a given time t defined as follows:
- If expr(t) < min(t), the result signal has the negative value expr(t)-min(t)
- If expr(t) > max(t), the result signal has the positive value expr(t)-max(t)
- Otherwise (expr(t) is between the bounds), the result signal has value 0.0
If either expr(t), min(t), or max(t) are undefined at some time t, the returned signal is defined at t as follows:
- in strict mode (if option
TPT.STRICT
is provided): the returned signal is undefined at t - in non-strict mode: the returned signal is 0.0 at t
Note that TPT.boundControl()
can be considered as a special form of the
TPT.hose()
function. The expression TPT.boundControl(expr, min, max)
has the same meaning as the equivalent term TPT.hose(expr, (max+min)/2, 0,
(max-min)/2). However, the implementation is more efficient.
Parameters:
expr Timed float expression that shall be checked
min Minimum bound for check
max Maximum bound for check
[options]
(optional)
if provided this option can only be TPT.STRICT
.
Returns:
Signal representing offset of expr(t) from the upper/lower bounds min(t)/max(t) (zero while expr(t) is between bounds, negative while below minimum bound, positive while above maximum bounds).
Examples:
res = TPT.Double(); # defines res in a way to check if expr mysignal(t) is inside bounds # bounds specified by the constant value -3 and signal "mymax" res(t) := TPT.boundControl(mysignal(t), -3, mymax(t));