OpenMetaverse.Utils.Clamp C# (CSharp) Method

Clamp() public static method

Clamp a given value between a range
public static Clamp ( double value, double min, double max ) : double
value double Value to clamp
min double Minimum allowable value
max double Maximum allowable value
return double
        public static double Clamp(double value, double min, double max)
        {
            // First we check to see if we're greater than the max
            value = (value > max) ? max : value;

            // Then we check to see if we're less than the min.
            value = (value < min) ? min : value;

            // There's no check to see if min > max.
            return value;
        }

Same methods

Utils::Clamp ( float value, float min, float max ) : float
Utils::Clamp ( int value, int min, int max ) : int

Usage Example

コード例 #1
0
ファイル: Vector2.cs プロジェクト: scatterp/plexview
 public static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max)
 {
     return(new Vector2(
                Utils.Clamp(value1.X, min.X, max.X),
                Utils.Clamp(value1.Y, min.Y, max.Y)));
 }
All Usage Examples Of OpenMetaverse.Utils::Clamp