Browse docsmath.clamp
On this page
API method

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));
    }
}
Reference details are generated from the Atlas Script schema in this documentation source snapshot. Confirm release-specific behavior in the Atlas for Windows build you use.