### robocode.util

# Class Utils

- `java.lang.Object`
- - `robocode.util.Utils`

`public class Utils`
`extends Object`

Utility class that provide methods for normalizing angles.

Authors:
  Mathew A. Nelson (original)
  Flemming N. Larsen (contributor)

  ## Field Summary

  `static double`

  `NEAR_DELTA`

  ## Method Summary

  `static Random`

  `getRandom()`
    Returns random number generator.

  `static boolean`

  `isNear(double value1, double value2)`
    Tests if the two `double` values are near to each other.

  `static double`

  `normalAbsoluteAngle(double angle)`
    Normalizes an angle to an absolute angle.

  `static double`

  `normalAbsoluteAngleDegrees(double angle)`
    Normalizes an angle to an absolute angle.

  `static double`

  `normalNearAbsoluteAngle(double angle)`
    Normalizes an angle to be near an absolute angle.

  `static double`

  `normalNearAbsoluteAngleDegrees(double angle)`
    Normalizes an angle to be near an absolute angle.

  `static double`

  `normalRelativeAngle(double angle)`
    Normalizes an angle to a relative angle.

  `static double`

  `normalRelativeAngleDegrees(double angle)`
    Normalizes an angle to a relative angle.

## Field Details

### NEAR_DELTA

    public static final double NEAR_DELTA

> Field Value:
>   0.0

## Method Details

### getRandom

    public static Random getRandom()

> Returns random number generator. It might be configured for repeatable behavior by setting -DRANDOMSEED option.
> Returns:
>   random number generator

### isNear

    public static boolean isNear(double value1,
                                 double value2)

> Tests if the two `double` values are near to each other. It is recommended to use this method instead of testing if the two doubles are equal using an this expression: `value1 == value2`. The reason being, that this expression might never become `true` due to the precision of double values. Whether or not the specified doubles are near to each other is defined by the following expression: `(Math.abs(value1 - value2) < .00001)`
> Parameters:
>   `value1` - the first double value
>   `value2` - the second double value
> Returns:
>   `true` if the two doubles are near to each other; `false` otherwise.

### normalAbsoluteAngle

    public static double normalAbsoluteAngle(double angle)

> Normalizes an angle to an absolute angle. The normalized angle will be in the range from 0 to 2*PI, where 2*PI itself is not included.
> Parameters:
>   `angle` - the angle to normalize
> Returns:
>   the normalized angle that will be in the range of [0,2*PI[

### normalAbsoluteAngleDegrees

    public static double normalAbsoluteAngleDegrees(double angle)

> Normalizes an angle to an absolute angle. The normalized angle will be in the range from 0 to 360, where 360 itself is not included.
> Parameters:
>   `angle` - the angle to normalize
> Returns:
>   the normalized angle that will be in the range of [0,360[

### normalNearAbsoluteAngle

    public static double normalNearAbsoluteAngle(double angle)

> Normalizes an angle to be near an absolute angle. The normalized angle will be in the range from 0 to 2*PI, where 2*PI itself is not included. If the normalized angle is near to 0, PI/2, PI, 3*PI/2 or 2*PI, that angle will be returned. The `isNear` method is used for defining when the angle is near one of angles listed above.
> Parameters:
>   `angle` - the angle to normalize
> Returns:
>   the normalized angle that will be in the range of [0,2*PI[
> See Also:
>   `normalAbsoluteAngle(double)`, `isNear(double,double)`

### normalNearAbsoluteAngleDegrees

    public static double normalNearAbsoluteAngleDegrees(double angle)

> Normalizes an angle to be near an absolute angle. The normalized angle will be in the range from 0 to 360, where 360 itself is not included. If the normalized angle is near to 0, 90, 180, 270 or 360, that angle will be returned. The `isNear` method is used for defining when the angle is near one of angles listed above.
> Parameters:
>   `angle` - the angle to normalize
> Returns:
>   the normalized angle that will be in the range of [0,360[
> See Also:
>   `normalAbsoluteAngle(double)`, `isNear(double,double)`

### normalRelativeAngle

    public static double normalRelativeAngle(double angle)

> Normalizes an angle to a relative angle. The normalized angle will be in the range from -PI to PI, where PI itself is not included.
> Parameters:
>   `angle` - the angle to normalize
> Returns:
>   the normalized angle that will be in the range of [-PI,PI[

### normalRelativeAngleDegrees

    public static double normalRelativeAngleDegrees(double angle)

> Normalizes an angle to a relative angle. The normalized angle will be in the range from -180 to 180, where 180 itself is not included.
> Parameters:
>   `angle` - the angle to normalize
> Returns:
>   the normalized angle that will be in the range of [-180,180[