You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Daniel Flassig edited this page Jul 17, 2026
·
1 revision
Clamps a number into an interval, or a vector component-wise.
r=pymath.clamp(t) -- clamp into [0, 1]r=pymath.clamp(t, min, max) -- clamp into [min, max]
Parameter
Type
Description
t
number or vector
The value to clamp.
min
number, vector or nil
Lower bound. A number applies to every component, a vector bounds each component individually. nil (as the argument, or as a single vector entry) means no lower bound.
max
number, vector or nil
Upper bound, like min.
Return value
Type
Description
r
The clamped number, or a new vector with each component clamped.
Notes:
With a single argument, the value is clamped into [0, 1].
For a scalar t the bounds must be numbers (or nil).