org.jbox2d.common
Class MathUtils

java.lang.Object
  extended by org.jbox2d.common.MathUtils

public class MathUtils
extends java.lang.Object

A few math methods that don't fit very well anywhere else.


Constructor Summary
MathUtils()
           
 
Method Summary
static float clamp(float a, float low, float high)
          Returns the closest value to 'a' that is in between 'low' and 'high'
static Vec2 clamp(Vec2 a, Vec2 low, Vec2 high)
           
static boolean isPowerOfTwo(int x)
           
static float max(float a, float b)
           
static float min(float a, float b)
           
static int nextPowerOfTwo(int x)
          Next Largest Power of 2: Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm that recursively "folds" the upper bits into the lower bits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtils

public MathUtils()
Method Detail

max

public static final float max(float a,
                              float b)

min

public static final float min(float a,
                              float b)

clamp

public static final float clamp(float a,
                                float low,
                                float high)
Returns the closest value to 'a' that is in between 'low' and 'high'


clamp

public static final Vec2 clamp(Vec2 a,
                               Vec2 low,
                               Vec2 high)

nextPowerOfTwo

public static final int nextPowerOfTwo(int x)
Next Largest Power of 2: Given a binary integer value x, the next largest power of 2 can be computed by a SWAR algorithm that recursively "folds" the upper bits into the lower bits. This process yields a bit vector with the same most significant 1 as x, but all 1's below it. Adding 1 to that value yields the next largest power of 2.


isPowerOfTwo

public static final boolean isPowerOfTwo(int x)