Class MathUtils

java.lang.Object
com.trimblemaps.mapsdk.utils.MathUtils

public class MathUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    clamp(double value, double min, double max)
    Test a value in specified range, returning minimum if it's below, and maximum if it's above
    static float
    clamp(float value, float min, float max)
    Test a value in specified range, returning minimum if it's below, and maximum if it's above
    static double
    normalize(double x, double dataLow, double dataHigh, double normalizedLow, double normalizedHigh)
    Scale a value from an arbitrary range to a normalized range.
    static double
    wrap(double value, double min, double max)
    Constrains value to the given range (including min, excluding max) via modular arithmetic.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MathUtils

      public MathUtils()
  • Method Details

    • clamp

      public static double clamp(double value, double min, double max)
      Test a value in specified range, returning minimum if it's below, and maximum if it's above
      Parameters:
      value - Value to test
      min - Minimum value of range
      max - Maximum value of range
      Returns:
      value if it's between min and max, min if it's below, max if it's above
    • clamp

      public static float clamp(float value, float min, float max)
      Test a value in specified range, returning minimum if it's below, and maximum if it's above
      Parameters:
      value - Value to test
      min - Minimum value of range
      max - Maximum value of range
      Returns:
      value if it's between min and max, min if it's below, max if it's above
    • wrap

      public static double wrap(double value, double min, double max)
      Constrains value to the given range (including min, excluding max) via modular arithmetic.

      Same formula as used in Core GL (wrap.hpp) std::fmod((std::fmod((value - min), d) + d), d) + min;

      Parameters:
      value - Value to wrap
      min - Minimum value
      max - Maximum value
      Returns:
      Wrapped value
    • normalize

      public static double normalize(double x, double dataLow, double dataHigh, double normalizedLow, double normalizedHigh)
      Scale a value from an arbitrary range to a normalized range.
      Parameters:
      x - The value to be normalized.
      dataLow - lowest expected value from a data set
      dataHigh - highest expected value from a data set
      normalizedLow - normalized lowest value
      normalizedHigh - normalized highest value
      Returns:
      The result of the normalization.