com.qualcomm.robotcore.util

## Class Range

- java.lang.Object
- - com.qualcomm.robotcore.util.Range

-     public class Range
      extends java.lang.Object

  Utility class for performing range operations

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte` | `clip(byte number, byte min, byte max)` clip 'number' if 'number' is less than 'min' or greater than 'max'
    `static double` | `clip(double number, double min, double max)` clip 'number' if 'number' is less than 'min' or greater than 'max'
    `static float` | `clip(float number, float min, float max)` clip 'number' if 'number' is less than 'min' or greater than 'max'
    `static int` | `clip(int number, int min, int max)` clip 'number' if 'number' is less than 'min' or greater than 'max'
    `static short` | `clip(short number, short min, short max)` clip 'number' if 'number' is less than 'min' or greater than 'max'
    `static double` | `scale(double n, double x1, double x2, double y1, double y2)` Scale a number in the range of x1 to x2, to the range of y1 to y2
    `static void` | `throwIfRangeIsInvalid(double number, double min, double max)` Throw an IllegalArgumentException if 'number' is less than 'min' or greater than 'max'
    `static void` | `throwIfRangeIsInvalid(int number, int min, int max)` Throw an IllegalArgumentException if 'number' is less than 'min' or greater than 'max'

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### scale

          public static double scale(double n,
                                     double x1,
                                     double x2,
                                     double y1,
                                     double y2)

      Scale a number in the range of x1 to x2, to the range of y1 to y2
      Parameters:
        `n` - number to scale
        `x1` - lower bound range of n
        `x2` - upper bound range of n
        `y1` - lower bound of scale
        `y2` - upper bound of scale
      Returns:
        a double scaled to a value between y1 and y2, inclusive

    - #### clip

          public static double clip(double number,
                                    double min,
                                    double max)

      clip 'number' if 'number' is less than 'min' or greater than 'max'
      Parameters:
        `number` - number to test
        `min` - minimum value allowed
        `max` - maximum value allowed

    - #### clip

          public static float clip(float number,
                                   float min,
                                   float max)

      clip 'number' if 'number' is less than 'min' or greater than 'max'
      Parameters:
        `number` - number to test
        `min` - minimum value allowed
        `max` - maximum value allowed

    - #### clip

          public static int clip(int number,
                                 int min,
                                 int max)

      clip 'number' if 'number' is less than 'min' or greater than 'max'
      Parameters:
        `number` - number to test
        `min` - minimum value allowed
        `max` - maximum value allowed

    - #### clip

          public static short clip(short number,
                                   short min,
                                   short max)

      clip 'number' if 'number' is less than 'min' or greater than 'max'
      Parameters:
        `number` - number to test
        `min` - minimum value allowed
        `max` - maximum value allowed

    - #### clip

          public static byte clip(byte number,
                                  byte min,
                                  byte max)

      clip 'number' if 'number' is less than 'min' or greater than 'max'
      Parameters:
        `number` - number to test
        `min` - minimum value allowed
        `max` - maximum value allowed

    - #### throwIfRangeIsInvalid

          public static void throwIfRangeIsInvalid(double number,
                                                   double min,
                                                   double max)
                                            throws java.lang.IllegalArgumentException

      Throw an IllegalArgumentException if 'number' is less than 'min' or greater than 'max'
      Parameters:
        `number` - number to test
        `min` - minimum value allowed
        `max` - maximum value allowed
      Throws:
        `java.lang.IllegalArgumentException` - if number is outside of range

    - #### throwIfRangeIsInvalid

          public static void throwIfRangeIsInvalid(int number,
                                                   int min,
                                                   int max)
                                            throws java.lang.IllegalArgumentException

      Throw an IllegalArgumentException if 'number' is less than 'min' or greater than 'max'
      Parameters:
        `number` - number to test
        `min` - minimum value allowed
        `max` - maximum value allowed
      Throws:
        `java.lang.IllegalArgumentException` - if number is outside of range