Package com.reportmill.base
Class RMMath
java.lang.Object
com.reportmill.base.RMMath
Utility methods for common math operations.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic NumberReturns the sum of the two given Numbers.static booleanbetween(float a, float x, float y) Returns whether a real number is between two other numbers.static floatclamp(double d) Returns the given double clamped to 1/1000th precision.static floatclamp(float f) Returns the given float clamped to 1/1000th precision.static floatclamp(float f, float min, float 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 floatcos(float anAngle) Returns the cos of the given angle in degrees.static NumberReturns 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(float a) Returns whether a real number is practically zero.static ListgetIntervalsFor(float maxValue) Returns well-chosen intervals from zero to a given a value.static ListgetIntervalsFor(float minValue, float maxValue) Return well-chosen intervals given a min/max value.static booleangt(float a, float b) Returns whether a real number is practically greater than another.static booleangte(float a, float b) Returns whether a real number is practically greater than or equal another.static booleanlt(float a, float b) Returns whether a real number is practically less than another.static booleanlte(float a, float 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 NumberReturns the product of the two given Numbers.static NumberReturns the negative of the given Number.static intReturns a random int.static IntegerReturns a random Integer.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(float 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 floatsin(float anAngle) Returns the sign of the given angle in degrees.static NumberReturns the difference of the two given Numbers.static floattrunc(float x, float y) Truncate x down to the nearest y.
- 
Constructor Details- 
RMMathpublic RMMath()
 
- 
- 
Method Details- 
equalspublic static boolean equals(double a, double b) Returns whether two real numbers are equal within a small tolerance.
- 
equalsZeropublic static boolean equalsZero(float a) Returns whether a real number is practically zero.
- 
gtpublic static boolean gt(float a, float b) Returns whether a real number is practically greater than another.
- 
gtepublic static boolean gte(float a, float b) Returns whether a real number is practically greater than or equal another.
- 
ltpublic static boolean lt(float a, float b) Returns whether a real number is practically less than another.
- 
ltepublic static boolean lte(float a, float b) Returns whether a real number is practically less than or equal another.
- 
betweenpublic static boolean between(float a, float x, float y) Returns whether a real number is between two other numbers.
- 
signpublic static int sign(float f) Returns the sign of a given number (as -1 or 1).
- 
sinpublic static float sin(float anAngle) Returns the sign of the given angle in degrees.
- 
cospublic static float cos(float anAngle) Returns the cos of the given angle in degrees.
- 
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.
- 
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).
- 
addReturns the sum of the two given Numbers.
- 
subtractReturns the difference of the two given Numbers.
- 
multiplyReturns the product of the two given Numbers.
- 
divideReturns the result of dividing n1 by n2.
- 
negateReturns the negative of the given Number.
- 
truncpublic static float trunc(float x, float y) Truncate x down to the nearest y.
- 
clamppublic static float clamp(float f) Returns the given float clamped to 1/1000th precision.
- 
clamppublic static float clamp(double d) Returns the given double 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(float f, float min, float 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.
- 
randomIntpublic static int randomInt()Returns a random int.
- 
randomIntegerReturns a random Integer.
- 
getIntervalsForReturn well-chosen intervals given a min/max value. For instance, (1,4) would return (1,2,3,4,5), while (17,242) would return (50,100,150,200,250). Useful methods for graphing.
- 
getIntervalsForReturns well-chosen intervals from zero to a given a value. Finds the first multiple of {5,10 or 25}*10^n that equals or exceeds max value, then divides by 5. This method could probably be done a lot simpler.
 
-