~~NOTOC~~ <=[[4rpl:start| Index]] \\ <=[[4rpl:start#math_utility| Math Utility]] ====== clamp ====== clamp(<-val <-min <-max) ===== Description ===== Clamps the given value between the given minimum and maximum values. Returns the given value if it is within the min and max range. Returns the min value if the given value is less than the min. Returns the max value if the given value is greater than the max value. Use Clamp to restrict a value to a range that is defined by the min and max values. If the value is a vector, each element of the vector is clamped separately. ===== Examples ===== trace(clamp(42 -10 10)) #prints '10' <=[[4rpl:start| Index]]