|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.util.Fixed
public class Fixed
Fixed point math library. Precision is 16 bits whole, 16 bits fractional. Uses 32 bit values to represent the Fixed number.
| Field Summary | |
|---|---|
static int |
FIXED_ONE
Positive one as a fixed point value. |
static int |
FIXED_ONE_HALF
Positive .5 as a fixed point value. |
static int |
FIXED_PI
Pi as a fixed point value. |
static int |
FIXED_TWO
Positive two as a fixed point value. |
static int |
MAX_VALUE
The largest fixed point value. |
| Constructor Summary | |
|---|---|
Fixed()
|
|
| Method Summary | |
|---|---|
static int |
abs(int value)
Returns the absolute value of a fixed point number. |
static int |
acosf(int cosf)
Returns the arccosine of a fixed point value. |
static int |
add(int fvalue1,
int fvalue2)
Returns the sum of two fixed point values. |
static int |
asinf(int sinf)
Returns the arcsine of a fixed point value. |
static int |
atanf(int tanf)
Returns the arctangent of a fixed point value. |
static int |
cos(int angle)
Returns the cosine of a whole number. |
static int |
cosf(int fAngle)
Returns the cosine of a fixed point value. |
static int |
divide(int dividend,
int divisor)
Divides a fixed point value by another fixed point value. |
static int |
floor(int fValue)
Returns the nearest whole number less than or equal to the specified fixed point value. |
static int |
fromInt(int value)
Given an integer value, return a fixed point value. |
static int |
fromReal(int whole,
int dividend,
int divisor)
Create a fixed point value from a real expression. |
static int |
getFraction(int fValue)
Given a fixed point value, return the fraction. |
static int |
hypot(int x,
int y)
Returns the hypotenuse of a right-angled triangle with sides of length x and y. |
static int |
multiply(int factor1,
int factor2)
Performs signed multiplication of two fixed point values. |
static int |
round(int fValue)
Returns the whole number nearest to the specified fixed point value. |
static int |
sin(int angle)
Returns the sine of a whole number. |
static int |
sinf(int fAngle)
Returns the sine of a fixed point value. |
static int |
sqrt(int fValue)
Returns the square root of a fixed point value. |
static int |
subtract(int fvalue1,
int fvalue2)
Returns the difference of two fixed point values. |
static int |
tan(int angle)
Returns the tangent of a whole number. |
static int |
tanf(int fAngle)
Returns the tangent of a fixed point value. |
static int |
toInt(int fvalue)
Given a fixed point value, return an integer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int FIXED_ONE
public static final int FIXED_TWO
public static final int FIXED_PI
public static final int MAX_VALUE
public static final int FIXED_ONE_HALF
| Constructor Detail |
|---|
public Fixed()
| Method Detail |
|---|
public static int fromInt(int value)
value - the whole number to convert
public static int toInt(int fvalue)
fvalue - the fixed point value to convert
public static int getFraction(int fValue)
fValue - the fixed point value
public static int fromReal(int whole,
int dividend,
int divisor)
whole - the whole numberdividend - the top of the fractiondivisor - the bottom of the fraction
IllegalArgumentException - if either dividend or divisor is negative and
whole is non-zeropublic static int abs(int value)
value - the fixed point value
value
public static int divide(int dividend,
int divisor)
dividend - value divided intodivisor - value divided by
ArithmeticException - if divisor is zero
public static int add(int fvalue1,
int fvalue2)
fvalue1 - the first fixed point valuefvalue2 - the second fixed point value
fvalue1 and
fvalue2, as a fixed point value
public static int subtract(int fvalue1,
int fvalue2)
fvalue1 - the first fixed point valuefvalue2 - the second fixed point value
fvalue1 and
fvalue2, as a fixed point value
public static int multiply(int factor1,
int factor2)
factor1 - the first fixed point valuefactor2 - the second fixed point value
public static int sinf(int fAngle)
fAngle - the fixed point angle in degrees
fAngle as a
fixed point valuepublic static int cosf(int fAngle)
fAngle - the fixed point angle in degrees
fAngle as a
fixed point valuepublic static int tanf(int fAngle)
fAngle - the fixed point angle in degrees
fAngle as a
fixed point value
ArithmeticException - if the cosine of
fAngle is zeropublic static int asinf(int sinf)
sinf - the fixed point sine value
sinf as a
fixed point value
ArithmeticException - if arcsine is undefined for
sinfpublic static int acosf(int cosf)
cosf - the fixed point cosine value
cosf as a
fixed point value
ArithmeticException - if arccosine is undefined for
cosfpublic static int atanf(int tanf)
tanf - the fixed point tangent value
tanf as a
fixed point valuepublic static int sin(int angle)
angle - the angle in degrees
angle as a
fixed point valuepublic static int cos(int angle)
angle - the angle in degrees
angle as a
fixed point valuepublic static int tan(int angle)
angle - the angle in degrees
angle as a
fixed point value
ArithmeticException - if the cosine of
angle is zeropublic static int floor(int fValue)
fValue - the fixed point value
fValue, as a whole numberpublic static int round(int fValue)
fValue - the fixed point value
fValue, as a fixed point value
public static int hypot(int x,
int y)
x and y. By
the Pythagorean theorem, this is equal to
sqrt(x**2 + y**2).
x - length of side x, as a fixed point valuey - length of side y, as a fixed point value
IllegalArgumentException - if ((x|y) < 0) || (x > 0x800000) || (y > 0x800000)public static int sqrt(int fValue)
Math.sqrt().
fValue - the fixed point value
fValue, as
a fixed point value
ArithmeticException - if fValue is
less than zeroMath.sqrt(double)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||