|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.kalmeo.util.MathFP
public abstract class MathFP
J2ME Fixed-Point Math Library
Provided under the artistic license: http://www.opensource.org/licenses/artistic-license.html
Basically it means you can use this library for free, even for commercial purposes.
References:
Field Summary | |
---|---|
static int |
DEFAULT_PRECISION
|
static int |
E
|
static int |
HALF
|
static int |
INFINITY
largest possible number |
static int |
ONE
|
static int |
PI
|
static int |
PI_HALF
|
static int |
PI_TWO
|
static int |
TWO
|
Constructor Summary | |
---|---|
MathFP()
|
Method Summary | |
---|---|
static int |
acos(int fp)
Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. |
static int |
asin(int fp)
Returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2. |
static int |
atan(int fp)
Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2. |
static int |
atan2(int fpX,
int fpY)
Returns the angle theta from the conversion of rectangular coordinates ( fpX , fpY ) to polar
coordinates (r, theta). |
static int |
ceil(int fp)
Returns the smallest (closest to negative infinity) fixed-point value that is greater than or equal to the argument and is equal to a mathematical integer. |
static int |
convert(int fp,
int precision)
Converts a fixed-point value to the current set precision. |
static int |
cos(int fp)
Returns the trigonometric cosine of an angle. |
static int |
div(int fp1,
int fp2)
Divides two fixed-point values. |
static int |
exp(int fp)
Returns Euler's number e raised to the power of a fixed-point value. |
static int |
floor(int fp)
Returns the largest (closest to positive infinity) fixed-point value value that is less than or equal to the argument and is equal to a mathematical integer. |
static int |
frac(int fp)
Returns the fractional part of a fixed-point value. |
static int |
fracAsInt(int fp)
Converts a fixed-point integer to an int with only the decimal value. |
static int |
getPrecision()
|
static int |
log(int x)
Returns the natural logarithm (base e) of a fixed-point value. |
static int |
log(int fp,
int base)
Returns the logarithm (base base ) of a fixed-point value. |
static int |
mul(int fp1,
int fp2)
Multiplies two fixed-point values. |
static int |
pow(int fp1,
int fp2)
Returns the value of the first argument raised to the power of the second argument |
static int |
round(int fp)
Returns the closest integer to the argument. |
static void |
setPrecision(int precision)
Sets the precision for all fixed-point operations. |
static int |
sin(int fp)
Returns the trigonometric sine of an angle. |
static int |
sqrt(int fp)
Returns the correctly rounded positive square root of a fixed-point value. |
static int |
tan(int fp)
Returns the trigonometric tangent of an angle. |
static int |
toDegrees(int fp)
Converts an angle measured in radians to an approximately equivalent angle measured in degrees. |
static int |
toFP(int i)
Converts an int to a fixed-point int. |
static int |
toFP(java.lang.String s)
Converts a string to a fixed-point value. |
static int |
toInt(int fp)
Converts a fixed-point value to an int. |
static int |
toRadians(int fp)
Converts an angle measured in degrees to an approximately equivalent angle measured in radians. |
static java.lang.String |
toString(int fp)
Converts a fixed-point value to a string. |
static int |
trunc(int fp)
Removes the fractional part of a fixed-point value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PRECISION
public static int ONE
public static int HALF
public static int TWO
public static int E
public static int PI
public static int PI_HALF
public static int PI_TWO
public static final int INFINITY
Constructor Detail |
---|
public MathFP()
Method Detail |
---|
public static int getPrecision()
public static void setPrecision(int precision)
precision
- the desired precision in number of bitspublic static int convert(int fp, int precision)
fp
- the fixed-point value to convert.precision
- the precision of the fixed-point value passed in.
public static int toFP(int i)
i
- int to convert.
public static int toFP(java.lang.String s)
.01 0.01 10 130.0 -30000.12345
s
- the string to convert.
public static int toInt(int fp)
fp
- fixed-point value to convert
public static java.lang.String toString(int fp)
toString(x, 0, max_possible_digits)
fp
- the fixed-point value to convert.
public static int ceil(int fp)
fp
- a fixed-point value.
public static int floor(int fp)
fp
- a fixed-point value.
public static int trunc(int fp)
fp
- the fixed-point value to truncate.
public static int frac(int fp)
fp
- a fixed-point value to get fractional part of.
public static int fracAsInt(int fp)
For example, if fp
represents 12.34
the
method returns 34
fp
- the fixed-point integer to be converted
public static int round(int fp)
fp
- the fixed-point value to round
public static int mul(int fp1, int fp2)
fp1
- first fixed-point value.fp2
- second fixed-point value.
public static int div(int fp1, int fp2)
fp1
- mumerator fixed-point value.fp2
- denominator fixed-point value.
public static int sqrt(int fp)
fp
- a fixed-point value.
fp
. If the argument
is NaN or less than zero, the result is NaN.public static int sin(int fp)
fp
- the angle in radians
public static int cos(int fp)
fp
- the angle in radians
public static int tan(int fp)
fp
- the angle in radians
public static int asin(int fp)
fp
- the fixed-point value whose arc sine is to be returned.
public static int acos(int fp)
fp
- the fixed-point value whose arc cosine is to be returned.
public static int atan(int fp)
fp
- the fiexed-point value whose arc tangent is to be returned.
public static int atan2(int fpX, int fpY)
fpX
, fpY
) to polar
coordinates (r, theta).
fpX
- the ordinate coordinatefpY
- the abscissa coordinate
public static int exp(int fp)
fp
- the exponent to raise e to.
fp
, where e
is the base of the natural logarithms.public static int log(int x)
fp
- a fixed-point value
a
, the natural logarithm of
fp
.public static int log(int fp, int base)
base
) of a fixed-point value.
fp
- a fixed-point valuebase
-
a
, the logarithm of
fp
public static int pow(int fp1, int fp2)
fp1
- the basefp2
- the exponent
ab
.public static int toRadians(int fp)
fp
- a fixed-point angle in degrees
public static int toDegrees(int fp)
fp
- a fixed-point angle in radians
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |