|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectat.emini.physics2D.util.FXUtil
public class FXUtil
Utilities for fixpoint math.
The float values postfixed with FX represent decimal numbers:
The first 20 bit are before the dot, the least 12 (DECIMAL
)bit represent everything after the decimal point.
So we have a precision of 2^-12 = 1/4096
Some small values also have "double precision". They are postfixed with 2FX and have 24 lower bits.
Methods with FX in the name (e.g: setValueFX(...), getValueFX(...)) make use of the FX number representation. That applies to both, input parameters and output parameters.
To perform fixpoint arithmetic the following has to be considered:
Results from multiplication or division have to be shifted back into the correct place.
Here is sample usage of adding, subtracting, multiplying and dividing values:
float rFX = aFX + bFX;
float rFX = aFX - bFX;
float rFX = (((aFX) * ( bFX)) );
float rFX = FXUtil.divideFX(aFX, bFX);
Field Summary | |
---|---|
static int |
ADD_MATRIX_DECIMAL
Additional matrix shift factor. |
static int |
DECIMAL
Shift Factor for single shifted numbers. |
static int |
DECIMAL2
Shift Factor for double shifted numbers. |
static short[] |
M_sinMatFX
Lookup table for sinus calculation. |
static float |
PI_2FX
Fixpoint Math representation of Pi (2FX). |
static float |
TWO_PI_2FX
Fixpoint Math representation of 2*Pi (2FX). |
Constructor Summary | |
---|---|
FXUtil()
|
Method Summary | |
---|---|
static float |
angleDiffFX(float angle1_2FX,
float angle2_2FX)
Returns the difference of two angles [-PI..PI]. |
static float |
angleInDegrees2FX(float angle2FX)
Returns the angle in degrees |
static float |
divideFX(float aFX,
float bFX)
Division of two fixpoint values. |
static float |
fromFX(float valueFX)
Converts a fixpoint value to integer |
static float |
multFX(float aFX,
float bFX)
Multiplication of two fixpoint values. |
static float |
toFX(int value)
Converts a value to fixpoint value (shifting). |
static float |
wrapAngleFX(float angle2FX)
Wraps an angle into the area [0..2*PI]. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short[] M_sinMatFX
int sinFX = FXUtil.sinMatFX[rotation2FX >> 16];
public static final int DECIMAL
public static final int DECIMAL2
public static final int ADD_MATRIX_DECIMAL
public static final float PI_2FX
public static final float TWO_PI_2FX
Constructor Detail |
---|
public FXUtil()
Method Detail |
---|
public static float wrapAngleFX(float angle2FX)
angle2FX
- the original angle(2FX).
public static float angleDiffFX(float angle1_2FX, float angle2_2FX)
angle1_2FX
- first angle (2FX).angle2_2FX
- second angle (2FX).
public static float angleInDegrees2FX(float angle2FX)
angle2FX
- angle to convert (2FX).
public static float multFX(float aFX, float bFX)
aFX
- value a to multiply (FX).bFX
- value b to multiply (FX).
public static float divideFX(float aFX, float bFX)
aFX
- value a to multiply (FX).bFX
- value b to multiply (FX).
public static float toFX(int value)
value
- the value to convert.
public static float fromFX(float valueFX)
valueFX
- the fixpoint value (FX)
|
Emini Physics Engine 1.3.5a API Documentation | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |