C# Class Box2D.Common.MathUtils

A few math methods that don't fit very well anywhere else.
Mostrar archivo Open project: gerich-home/box2dnet

Public Properties

Property Type Description
DEG2_RAD float
HALF_PI float
INV_PI float
PI float
QUATER_PI float
RAD2_DEG float
THREE_HALVES_PI float
TWO_PI float

Public Methods

Method Description
Abs ( float x ) : float
Abs ( int x ) : int
Atan2 ( float y, float x ) : float
Ceil ( float x ) : int
CeilPowerOf2 ( int x ) : int

Rounds up the value to the nearest higher power^2 value.

Clamp ( Vec2 a, Vec2 low, Vec2 high ) : Vec2
Clamp ( float a, float low, float high ) : float

Returns the closest value to 'a' that is in between 'low' and 'high'

ClampToOut ( Vec2 a, Vec2 low, Vec2 high, Vec2 dest ) : void
Cos ( float x ) : float
Distance ( Vec2 v1, Vec2 v2 ) : float
DistanceSquared ( Vec2 v1, Vec2 v2 ) : float
FastAtan2 ( float y, float x ) : float
FastPow ( float a, float b ) : float
Floor ( float x ) : int
IsPowerOfTwo ( int x ) : bool
Map ( float val, float fromMin, float fromMax, float toMin, float toMax ) : float
Max ( float a, float b ) : float
Max ( int a, int b ) : int
Min ( float a, float b ) : float
Min ( int a, int b ) : int
NextPowerOfTwo ( int x ) : int

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.

Pow ( float a, float b ) : float

Computes a fast approximation to Math.pow(a, b). Adapted from http://www.dctsystems.co.uk/Software/power.html.

RandomFloat ( Random r, float argLow, float argHigh ) : float
RandomFloat ( float argLow, float argHigh ) : float
ReduceAngle ( float theta ) : float
Round ( float x ) : int
Sin ( float x ) : float
SinLut ( float x ) : float
Sqrt ( float x ) : float

Private Methods

Method Description
FloatToIntBits ( float number ) : int
MathUtils ( ) : System

Method Details

Abs() public static method

public static Abs ( float x ) : float
x float
return float

Abs() public static method

public static Abs ( int x ) : int
x int
return int

Atan2() public static method

public static Atan2 ( float y, float x ) : float
y float
x float
return float

Ceil() public static method

public static Ceil ( float x ) : int
x float
return int

CeilPowerOf2() public static method

Rounds up the value to the nearest higher power^2 value.
public static CeilPowerOf2 ( int x ) : int
x int
return int

Clamp() public static method

public static Clamp ( Vec2 a, Vec2 low, Vec2 high ) : Vec2
a Vec2
low Vec2
high Vec2
return Vec2

Clamp() public static method

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

ClampToOut() public static method

public static ClampToOut ( Vec2 a, Vec2 low, Vec2 high, Vec2 dest ) : void
a Vec2
low Vec2
high Vec2
dest Vec2
return void

Cos() public static method

public static Cos ( float x ) : float
x float
return float

Distance() public static method

public static Distance ( Vec2 v1, Vec2 v2 ) : float
v1 Vec2
v2 Vec2
return float

DistanceSquared() public static method

public static DistanceSquared ( Vec2 v1, Vec2 v2 ) : float
v1 Vec2
v2 Vec2
return float

FastAtan2() public static method

public static FastAtan2 ( float y, float x ) : float
y float
x float
return float

FastPow() public static method

public static FastPow ( float a, float b ) : float
a float
b float
return float

Floor() public static method

public static Floor ( float x ) : int
x float
return int

IsPowerOfTwo() public static method

public static IsPowerOfTwo ( int x ) : bool
x int
return bool

Map() public static method

public static Map ( float val, float fromMin, float fromMax, float toMin, float toMax ) : float
val float
fromMin float
fromMax float
toMin float
toMax float
return float

Max() public static method

public static Max ( float a, float b ) : float
a float
b float
return float

Max() public static method

public static Max ( int a, int b ) : int
a int
b int
return int

Min() public static method

public static Min ( float a, float b ) : float
a float
b float
return float

Min() public static method

public static Min ( int a, int b ) : int
a int
b int
return int

NextPowerOfTwo() public static method

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.
public static NextPowerOfTwo ( int x ) : int
x int
return int

Pow() public static method

Computes a fast approximation to Math.pow(a, b). Adapted from http://www.dctsystems.co.uk/Software/power.html.
public static Pow ( float a, float b ) : float
a float a positive number
b float a number
return float

RandomFloat() public static method

public static RandomFloat ( Random r, float argLow, float argHigh ) : float
r System.Random
argLow float
argHigh float
return float

RandomFloat() public static method

public static RandomFloat ( float argLow, float argHigh ) : float
argLow float
argHigh float
return float

ReduceAngle() public static method

public static ReduceAngle ( float theta ) : float
theta float
return float

Round() public static method

public static Round ( float x ) : int
x float
return int

Sin() public static method

public static Sin ( float x ) : float
x float
return float

SinLut() public static method

public static SinLut ( float x ) : float
x float
return float

Sqrt() public static method

public static Sqrt ( float x ) : float
x float
return float

Property Details

DEG2_RAD public_oe static_oe property

Degrees to radians conversion factor
public static float DEG2_RAD
return float

HALF_PI public_oe static_oe property

public static float HALF_PI
return float

INV_PI public_oe static_oe property

public static float INV_PI
return float

PI public_oe static_oe property

public static float PI
return float

QUATER_PI public_oe static_oe property

public static float QUATER_PI
return float

RAD2_DEG public_oe static_oe property

Radians to degrees conversion factor
public static float RAD2_DEG
return float

THREE_HALVES_PI public_oe static_oe property

public static float THREE_HALVES_PI
return float

TWO_PI public_oe static_oe property

public static float TWO_PI
return float