Name Edit

clamp - returns smallest integer not less than a scalar or each vector component.

Synopsis Edit

vector1 clamp(vector1 x, vector a, vector b);
vector2 clamp(vector2 x, vector a, vector b);
vector3 clamp(vector3 x, vector a, vector b);
vector4 clamp(vector4 x, vector a, vector b);

Parameters Edit

Vector or scalar to clamp.
Vector or scalar for bottom of clamp range.
Vector or scalar for top of clamp range.

Description Edit

Returns x clamped to the range [a,b] as follows:

1) Returns a if x is less than a; else
2) Returns b if x is greater than b; else
3) Returns x otherwise.

For vectors, the returned vector contains the clamped result of each element of the vector x clamped using the respective element of vectors a and b.