boundControlRel
timed_float TPT.boundControlRel(timed_float expr, timed_float ref, timed_float percentage, [int options])
This function generates relative bounds around the time dependent expression ref(t) and checks if the signal expr(t) is encapsulated within these bounds. The bounds are specified based on the reference signal ref(t) and the percentage percentage(t) as follows:
- lower_bounds(t) := ref(t) - ref(t) * (percentage(t)/100.0)
- upper_bounds(t) := ref(t) + ref(t) * (percentage(t)/100.0)
- If expr(t) < lower_bounds(t), the result signal has the negative value expr(t)-lower_bounds(t)
- If expr(t) > upper_bounds(t), the result signal has the positive value expr(t)-upper_bounds(t)
- Otherwise (expr(t) is between the bounds), the result signal has value 0.0
If either expr(t), ref(t), or percentage(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
Parameters:
expr Timed float expression that shall be checked
ref Reference timed float expression defining the bounds
percentage Non-negative percentage expanding the reference signal to minimum and maximum bounds
[options]
(optional)
if provided this option can only be TPT.STRICT
.
Returns:
Signal representing offset of expr(t) from the upper/lower bounds.
Examples:
res = TPT.Double(); # defines res in a way to check if mysignal(t) is inside bounds # bounds specified by ref and percentage: (0.5*t-1)±30% res(t) := TPT.boundControlRel(mysignal(t), 0.5*t-1, 30);