math.clamp

From Wake
Jump to: navigation, search

Clamp a value between a minimum and maximum. Supports numbers and vector types. Vectors will have their components clamped between the same indices of the minimum/maximum vectors. All parameters must be of the same type, and the return value will be of the same type as the parameters.

Function

Synopsis

result = math.clamp(x, min, max)

Arguments

number,Vector2,Vector3,Vector4 x

The value to clamp.


number,Vector2,Vector3,Vector4 min

The minimum value.


number,Vector2,Vector3,Vector4 max

The maximum value.

Returns

number,Vector2,Vector3,Vector4 result

The clamped value.

Notes

  • This function implies the argument type based on the first argument. As such, you may not use table shorthand for the first argument if it is supposed to be a vector.

See Also