smooth(
var* value,var factor);
Smoothes out the given value using the given smoothing factor. This function can be used for letting a parameter - such as an angle - softly approach a target value, or for smoothing jerky input values.
Parameters:
value |
Global
variable to be smoothed out. |
factor |
Smoothing factor in the range of 0 .. 0.999. 0 means no smoothing, 0.999 means extreme smoothing. |
Returns:
Smoothed value.
Speed:
Fast
Remarks:
The previous smoothing values are stored in an internal 64-variable buffer, meaning that up to 64 variables can be smoothed by this function. Smoothing more than 64 variables at the same time leads to non-smoothed return values.
Algorithm:
value = var * (1-factor) + last_value * factor
Example (lite-C):
function approach_target_angle(angle)
{
while (abs(my.pan - angle) > 0.1) {
my.pan = angle;
smooth(my.pan,0.95);
wait(1);
}
}
See also:
accelerate, clamp
► latest
version online