Package com.inductiveautomation.rm.base
Class RMMath
- java.lang.Object
- 
- com.inductiveautomation.rm.base.RMMath
 
- 
 public class RMMath extends java.lang.ObjectUtility methods for common math operations.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classRMMath.RMFuncA class used to specify an arbitrary mathematical function.
 - 
Constructor SummaryConstructors Constructor Description RMMath()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Numberadd(java.lang.Number n1, java.lang.Number n2)Returns the sum of the two given Numbers.static booleanbetween(double a, double x, double y)Returns whether a real number is between two other numbers.static doubleceil(double x, double y)Truncate x up to the nearest y.static doubleclamp(double f)Returns the given float clamped to 1/1000th precision.static floatclamp(double f, double min, double max)Returns the given double clamped between the two values.static intclamp(int i, int min, int max)Returns the given in clamped between the two values.static doubleclamp_doubleback(double a, double x, double y)Returns the given double clamped between the two values.static doubleclamp_wrap(double a, double x, double y)Returns the given double clamped between the two values (wraps around if out of range).static intclamp_wrap(int a, int x, int y)Returns the given double clamped between the two values (wraps around if out of range).static doublecos(double anAngle)Returns the cos of the given angle in degrees.static java.lang.Numberdivide(java.lang.Number n1, java.lang.Number n2)Returns the result of dividing n1 by n2.static booleanequals(double a, double b)Returns whether two real numbers are equal within a small tolerance.static booleanequalsZero(double a)Returns whether a real number is practically zero.static doublefloor(double x, double y)Truncate x down to the nearest y.static booleangt(double a, double b)Returns whether a real number is practically greater than another.static booleangte(double a, double b)Returns whether a real number is practically greater than or equal another.static booleanlt(double a, double b)Returns whether a real number is practically less than another.static booleanlte(double a, double b)Returns whether a real number is practically less than or equal another.static doublemod(double x, double y)Returns the given number modulo the second number (mod for floats).static java.lang.Numbermultiply(java.lang.Number n1, java.lang.Number n2)Returns the product of the two given Numbers.static java.lang.Numbernegate(java.lang.Number aNumber)Returns the negative of the given Number.static floatrandomFloat(float aVal)Returns a random float up to given value.static intrandomInt()Returns a random int.static doubleround(double x, double y)Returns the given number rounded to the second number (rounding to arbitrary double values).static floatround(float x, float y)Returns the given number rounded to the second number (rounding to arbitrary floating values).static intsign(double f)Returns the sign of a given number (as -1 or 1).static doublesin(double anAngle)Returns the sign of the given angle in degrees.static java.lang.Numbersubtract(java.lang.Number n1, java.lang.Number n2)Returns the difference of the two given Numbers.static doubletrunc(double x, double y)Truncate x down to the nearest y.
 
- 
- 
- 
Method Detail- 
equalspublic static boolean equals(double a, double b)Returns whether two real numbers are equal within a small tolerance.
 - 
equalsZeropublic static boolean equalsZero(double a) Returns whether a real number is practically zero.
 - 
gtpublic static boolean gt(double a, double b)Returns whether a real number is practically greater than another.
 - 
gtepublic static boolean gte(double a, double b)Returns whether a real number is practically greater than or equal another.
 - 
ltpublic static boolean lt(double a, double b)Returns whether a real number is practically less than another.
 - 
ltepublic static boolean lte(double a, double b)Returns whether a real number is practically less than or equal another.
 - 
betweenpublic static boolean between(double a, double x, double y)Returns whether a real number is between two other numbers.
 - 
signpublic static int sign(double f) Returns the sign of a given number (as -1 or 1).
 - 
modpublic static double mod(double x, double y)Returns the given number modulo the second number (mod for floats).
 - 
roundpublic static float round(float x, float y)Returns the given number rounded to the second number (rounding to arbitrary floating values).
 - 
roundpublic static double round(double x, double y)Returns the given number rounded to the second number (rounding to arbitrary double values).
 - 
truncpublic static double trunc(double x, double y)Truncate x down to the nearest y.
 - 
floorpublic static double floor(double x, double y)Truncate x down to the nearest y.
 - 
ceilpublic static double ceil(double x, double y)Truncate x up to the nearest y.
 - 
clamppublic static double clamp(double f) Returns the given float clamped to 1/1000th precision.
 - 
clamppublic static int clamp(int i, int min, int max)Returns the given in clamped between the two values.
 - 
clamppublic static float clamp(double f, double min, double max)Returns the given double clamped between the two values.
 - 
clamp_wrappublic static int clamp_wrap(int a, int x, int y)Returns the given double clamped between the two values (wraps around if out of range).
 - 
clamp_wrappublic static double clamp_wrap(double a, double x, double y)Returns the given double clamped between the two values (wraps around if out of range).
 - 
clamp_doublebackpublic static double clamp_doubleback(double a, double x, double y)Returns the given double clamped between the two values.
 - 
negatepublic static java.lang.Number negate(java.lang.Number aNumber) Returns the negative of the given Number.
 - 
addpublic static java.lang.Number add(java.lang.Number n1, java.lang.Number n2)Returns the sum of the two given Numbers.
 - 
subtractpublic static java.lang.Number subtract(java.lang.Number n1, java.lang.Number n2)Returns the difference of the two given Numbers.
 - 
multiplypublic static java.lang.Number multiply(java.lang.Number n1, java.lang.Number n2)Returns the product of the two given Numbers.
 - 
dividepublic static java.lang.Number divide(java.lang.Number n1, java.lang.Number n2)Returns the result of dividing n1 by n2.
 - 
sinpublic static double sin(double anAngle) Returns the sign of the given angle in degrees.
 - 
cospublic static double cos(double anAngle) Returns the cos of the given angle in degrees.
 - 
randomIntpublic static int randomInt() Returns a random int.
 - 
randomFloatpublic static float randomFloat(float aVal) Returns a random float up to given value.
 
- 
 
-