clamp
This function clamps an input two an upper or lower bound, or min / max values.
It returns the value a when t is less than a, the value t when t is between a and b, and the value b when t is greater than b.
/*
** Usage:
** clamp(t,a,b)
**
** Arguments:
** t value, real
** a lower bound, real
** b upper bound, real
**
** Returns:
** (a) when (t < a), (b) when (t > b),
** (t) otherwise
**
** GMLscripts.com
*/
{
if (argument0 < argument1) return argument1;
if (argument0 > argument2) return argument2;
return argument0;
}
** Usage:
** clamp(t,a,b)
**
** Arguments:
** t value, real
** a lower bound, real
** b upper bound, real
**
** Returns:
** (a) when (t < a), (b) when (t > b),
** (t) otherwise
**
** GMLscripts.com
*/
{
if (argument0 < argument1) return argument1;
if (argument0 > argument2) return argument2;
return argument0;
}
[Please Login]
Projects: 2
Contributor: xot
comments powered by Disqus

Related: