Condensed clamp() methods

Found a way to condense the clamp() methods by replacing the if statements with a ternary operator.