Package mgui.numbers

Class NumberFunctions

java.lang.Object
mgui.numbers.NumberFunctions

public class NumberFunctions
extends java.lang.Object
  • Constructor Details

    • NumberFunctions

      public NumberFunctions()
  • Method Details

    • compare

      public static int compare​(double d1, double d2, double precision)
      Compares two numbers within a given precision (number of zeros). Returns -1 if d1 < d2, +1 if d1 > d2, zero otherwise.
      Parameters:
      d1 -
      d2 -
      precision -
      Returns:
    • getMultiple

      public static int getMultiple​(double d1, double d2)
    • ceilToOdd

      public static int ceilToOdd​(double d)
    • getInstance

      public static MguiNumber getInstance​(DataType type, double value)
      Returns an instance of an MguiNumber of the specified type and value
      Parameters:
      type -
      value -
      Returns:
    • getInstance

      public static MguiNumber getInstance​(java.lang.Class<?> clazz, double value)
      Returns an instance of an MguiNumber of the specified class and value. Returns null if instantiation failed.
      Parameters:
      type -
      value -
      Returns:
    • getInstance

      public static MguiNumber getInstance​(java.lang.String type, double value)
      Returns an instance of an MguiNumber of the specified type and value
      Parameters:
      type - : Name of MguiNumber subclass
      value -
      Returns:
    • getDecimalFormat

      public static java.text.DecimalFormat getDecimalFormat​(int decimal_places)
    • getDecimalFormat

      public static java.text.DecimalFormat getDecimalFormat​(int decimal_places, boolean dividers)
    • getPoint2fStr

      public static java.lang.String getPoint2fStr​(org.jogamp.vecmath.Point2f p, java.lang.String pattern)
    • isEven

      public static boolean isEven​(double value)
    • getPoint3dStr

      public static java.lang.String getPoint3dStr​(org.jogamp.vecmath.Point3d p, java.lang.String pattern)
    • getDifference

      public static MguiDouble getDifference​(MguiNumber n1, MguiNumber n2)
    • getProduct

      public static MguiDouble getProduct​(MguiNumber n1, MguiNumber n2)
    • getQuotient

      public static MguiDouble getQuotient​(MguiNumber n1, MguiNumber n2)
    • getSum

      public static MguiDouble getSum​(MguiNumber n1, MguiNumber n2)
    • getNextSquare

      public static double getNextSquare​(double n)
      Returns the next highest square number
    • getSum

      public static double getSum​(double[] n)
    • getReasonableString

      public static java.lang.String getReasonableString​(double d)
    • getReasonableFormat

      public static java.lang.String getReasonableFormat​(double d)
    • getValueForObject

      public static double getValueForObject​(java.lang.Object obj)
      Determines the numeric value of obj and returns it as a double. obj must be an instance of arNumber, or a Java primitive wrapper (one of Integer, Short, Float, or Double).

      If obj does not satisfy these criteria, Double.NaN is returned.

      Parameters:
      obj -
      Returns:
    • isNumeric

      public static boolean isNumeric​(java.lang.Object obj)
      Determines whether obj is numeric; i.e., an instance of MguiNumber (except arBoolean), or a Java primitive wrapper (one of Integer, Short, Float, or Double).
      Parameters:
      obj -
      Returns:
      true if numeric, false otherwise.