On this page
math.clamp
Clamps a numeric expression within the min/max range.
Syntax
Atlas Script
math.clamp(expression, min, max)Parameters
expression- Numeric expression evaluated by this math method.
min- Lower bound for the calculation or generated value.
max- Upper bound for the calculation or generated value.
Return value
See the remarks for the returned value and runtime behavior.
Remarks
Clamps a numeric expression within the min/max range.
Examples
Curve trigger pressure.atlas
event on_input() {
var sourcePressure = input.get(ps5.l2);
if (sourcePressure > 0) {
var curved = math.pow(sourcePressure / 100, 2) * 100;
output.set_trigger("R2", math.clamp(curved, 0, 100));
}
}