net.jinx.math
Class MathUtil

java.lang.Object
  extended by net.jinx.math.MathUtil

public class MathUtil
extends java.lang.Object

Provides utility methods for various mathematical and physics operations.

API Stability: Beta; the main(String[]) method isn't staying.


Field Summary
static float E
           
static float PI
           
 
Method Summary
static float acos(float theta)
           
static float asin(float t)
           
static float atan(float theta)
           
static float atan2(float y, float x)
           
static Vector calcCenterOfMass(Vector[] positions, float[] masses)
          Calculates the center of mass for a set of point masses in object space.
static Matrix3 calcInertiaTensor(Vector[] positions, float[] masses)
          Calculates an inertia tensor from a set of point masses and their positions in object space.
static float cos(float theta)
           
static void main(java.lang.String[] args)
          Test method.
static float sin(float t)
           
static float sqrt(float v)
           
static float tan(float theta)
           
static float toDegrees(float theta)
           
static float toRadians(float theta)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

E

public static final float E
See Also:
Constant Field Values

PI

public static final float PI
See Also:
Constant Field Values
Method Detail

sin

public static float sin(float t)

cos

public static float cos(float theta)

tan

public static float tan(float theta)

asin

public static float asin(float t)

acos

public static float acos(float theta)

atan

public static float atan(float theta)

atan2

public static float atan2(float y,
                          float x)

sqrt

public static float sqrt(float v)

toDegrees

public static float toDegrees(float theta)

toRadians

public static float toRadians(float theta)

calcCenterOfMass

public static Vector calcCenterOfMass(Vector[] positions,
                                      float[] masses)
Calculates the center of mass for a set of point masses in object space.

Parameters:
positions - the positions of the point masses.
masses - the masses of the point masses.
Returns:
the center as a Vector.
Throws:
java.lang.IllegalArgumentException - if positions and masses aren't the same length or if the input arrays are empty.

calcInertiaTensor

public static Matrix3 calcInertiaTensor(Vector[] positions,
                                        float[] masses)
Calculates an inertia tensor from a set of point masses and their positions in object space.

Parameters:
positions - the positions of the point masses.
masses - the masses of the point masses.
Returns:
the intertia tensor as a Matrix3.
Throws:
java.lang.IllegalArgumentException - if positions and masses aren't the same length or if the input arrays are empty.

main

public static void main(java.lang.String[] args)
Test method. This is not a permanent method; don't cound on it staying.