Math Class Reference

Some extensions to the math/vector lib. More...

List of all members.

Classes

class  RandGenerator
 Wrap System.Random and extend with vector random generation. More...

Static Public Member Functions

static Matrix4 LookAt (Vector3 eye, Vector3 center, Vector3 _Up)
 Compute a lookat matrix for the camera.
static void TranslationRotationScale (ref Matrix3 ret, Vector2 translation, Vector2 rotation, Vector2 scale)
 Fast build of a Matrix3 TRS matrix.
static float Det (Vector2 value1, Vector2 value2)
 Return the determinant formed by 2 vectors.
static float Sign (float x)
 Return the sign of x (returns 0.0f is x=0.0f).
static Vector2 Perp (Vector2 value)
 Return value rotated by pi/2.
static Vector4 SetAlpha (Vector4 value, float w)
 Set alpha (can be inlined in math expressions).
static float SafeAcos (float x)
 SafeAcos checks that x is in [-1,1], and if x is off by an epsilon it clamps it.
static float Angle (Vector2 value)
 Return the absolute 2d angle formed by (1,0) and value, in range -pi,pi.
static Vector2 Rotate (Vector2 point, float angle, Vector2 pivot)
 Rotate 'point' around rotation center 'pivot' by an angle 'angle' (radians).
static float Deg2Rad (float value)
 Degree to radians.
static float Rad2Deg (float value)
 Radians to degrees.
static Vector2 Deg2Rad (Vector2 value)
 Element wise degree to radians.
static Vector2 Rad2Deg (Vector2 value)
 Element wise radians to degrees.
static float Lerp (float a, float b, float x)
 Linear interpolation.
static Vector2 Lerp (Vector2 a, Vector2 b, float x)
 Linear interpolation.
static Vector3 Lerp (Vector3 a, Vector3 b, float x)
 Linear interpolation.
static Vector4 Lerp (Vector4 a, Vector4 b, float x)
 Linear interpolation.
static Vector2 LerpUnitVectors (Vector2 va, Vector2 vb, float x)
 Lerp 2 (assumed) unit vectors (shortest path).
static float LerpAngles (float a, float b, float x)
 Lerp 2 angle values (shortest path).
static float Sin (uint period, float phase, uint mstime)
 A "safe" sine function taking uint values.
static float Sin (ulong period, float phase, ulong mstime)
 A "safe" sine function taking ulong values.
static float Linear (float x)
 This is just f(x)=x, named so that code is more explicit when it is passed as a tween function.
static float PowerfulScurve (float x, float p1, float p2)
 A very controlable s curve, lets you do polynomial ease in/out curves with little code.
static float PowEaseIn (float x, float p)
 Ease in curve using Pow.
static float PowEaseOut (float x, float p)
 Ease out curve using Pow.
static float PowEaseInOut (float x, float p)
 PowEaseIn/PowEaseOut mirrored around 0.5,0.5.
static float ExpEaseOut (float x, float a)
 Ease out curve using a 1-exp(-a*x) exponential, but normalized so that we reach 1 when x=1.
static float ExpEaseIn (float x, float a)
 Ease in curve using an exponential.
static float BackEaseIn (float x, float a)
 BackEaseIn function (see http://www.robertpenner.com)
static float BackEaseOut (float x, float a)
 BackEaseOut function (see http://www.robertpenner.com)
static float BackEaseInOut (float x, float p)
 BackEaseIn/BackEaseOut mirrored around 0.5,0.5.
static float Impulse (float x, float b)
 Impulse function (source Inigo Quilez).
static float ShockWave (float d, float time, float wave_half_width, float wave_speed, float wave_fade, float d_scale)
 Travelling wave function.
static int Log2 (int v)
 Return the log of v in base 2.
static bool IsPowerOf2 (int i)
 Return true if 'i' is a power of 2.
static int GreatestOrEqualPowerOf2 (int i)
 Return the closest greater or equal power of 2.
static Vector2 ClosestSegmentPoint (Vector2 P, Vector2 A, Vector2 B)
 Return the closest point to P that's on segment [A,B].

Static Public Attributes

static Vector2i _00i = new Vector2i(0,0)
static Vector2i _10i = new Vector2i(1,0)
static Vector2i _01i = new Vector2i(0,1)
static Vector2i _11i = new Vector2i(1,1)
static Vector3i _000i = new Vector3i(0,0,0)
static Vector3i _100i = new Vector3i(1,0,0)
static Vector3i _010i = new Vector3i(0,1,0)
static Vector3i _110i = new Vector3i(1,1,0)
static Vector3i _001i = new Vector3i(0,0,1)
static Vector3i _101i = new Vector3i(1,0,1)
static Vector3i _011i = new Vector3i(0,1,1)
static Vector3i _111i = new Vector3i(1,1,1)
static Vector2 _00 = new Vector2(0.0f,0.0f)
static Vector2 _10 = new Vector2(1.0f,0.0f)
static Vector2 _01 = new Vector2(0.0f,1.0f)
static Vector2 _11 = new Vector2(1.0f,1.0f)
static Vector3 _000 = new Vector3(0.0f,0.0f,0.0f)
static Vector3 _100 = new Vector3(1.0f,0.0f,0.0f)
static Vector3 _010 = new Vector3(0.0f,1.0f,0.0f)
static Vector3 _110 = new Vector3(1.0f,1.0f,0.0f)
static Vector3 _001 = new Vector3(0.0f,0.0f,1.0f)
static Vector3 _101 = new Vector3(1.0f,0.0f,1.0f)
static Vector3 _011 = new Vector3(0.0f,1.0f,1.0f)
static Vector3 _111 = new Vector3(1.0f,1.0f,1.0f)
static Vector4 _0000 = new Vector4(0.0f,0.0f,0.0f,0.0f)
static Vector4 _1000 = new Vector4(1.0f,0.0f,0.0f,0.0f)
static Vector4 _0100 = new Vector4(0.0f,1.0f,0.0f,0.0f)
static Vector4 _1100 = new Vector4(1.0f,1.0f,0.0f,0.0f)
static Vector4 _0010 = new Vector4(0.0f,0.0f,1.0f,0.0f)
static Vector4 _1010 = new Vector4(1.0f,0.0f,1.0f,0.0f)
static Vector4 _0110 = new Vector4(0.0f,1.0f,1.0f,0.0f)
static Vector4 _1110 = new Vector4(1.0f,1.0f,1.0f,0.0f)
static Vector4 _0001 = new Vector4(0.0f,0.0f,0.0f,1.0f)
static Vector4 _1001 = new Vector4(1.0f,0.0f,0.0f,1.0f)
static Vector4 _0101 = new Vector4(0.0f,1.0f,0.0f,1.0f)
static Vector4 _1101 = new Vector4(1.0f,1.0f,0.0f,1.0f)
static Vector4 _0011 = new Vector4(0.0f,0.0f,1.0f,1.0f)
static Vector4 _1011 = new Vector4(1.0f,0.0f,1.0f,1.0f)
static Vector4 _0111 = new Vector4(0.0f,1.0f,1.0f,1.0f)
static Vector4 _1111 = new Vector4(1.0f,1.0f,1.0f,1.0f)
static Vector4 UV_TransformIdentity = new Vector4( 0.0f, 0.0f, 1.0f, 1.0f )
 UV transform stored as (offset, scale) in a Vector4.
static Vector4 UV_TransformFlipV = new Vector4( 0.0f, 1.0f, 1.0f, -1.0f )
 UV transform stored as (offset, scale) in a Vector4 UV_TransformFlipV v into 1-v, and leaves u unchanged.

Properties

static float Pi [get]
static float TwicePi [get]
 2pi
static float HalfPi [get]
 pi/2

Detailed Description

Some extensions to the math/vector lib.


Member Function Documentation

static Matrix4 LookAt ( Vector3  eye,
Vector3  center,
Vector3  _Up 
) [static]

Compute a lookat matrix for the camera.

The vector (eye, center) maps to -z (since OpenGL looks downward z), and up maps to y.

static float PowEaseInOut ( float  x,
float  p 
) [static]

PowEaseIn/PowEaseOut mirrored around 0.5,0.5.

Same exponent in and out.

static float PowerfulScurve ( float  x,
float  p1,
float  p2 
) [static]

A very controlable s curve, lets you do polynomial ease in/out curves with little code.

Parameters:
xAsssumed to be in 0,1.
p1Controls the ease in exponent (if >1).
p2Controls the ease out exponent (if >1.,(p1,p2)=(1,1) just gives f(x)=x

Member Data Documentation

Vector2 _00 = new Vector2(0.0f,0.0f) [static]
Vector3 _000 = new Vector3(0.0f,0.0f,0.0f) [static]
Vector4 _0000 = new Vector4(0.0f,0.0f,0.0f,0.0f) [static]
Vector4 _0001 = new Vector4(0.0f,0.0f,0.0f,1.0f) [static]
Vector3i _000i = new Vector3i(0,0,0) [static]
Vector3 _001 = new Vector3(0.0f,0.0f,1.0f) [static]
Vector4 _0010 = new Vector4(0.0f,0.0f,1.0f,0.0f) [static]
Vector4 _0011 = new Vector4(0.0f,0.0f,1.0f,1.0f) [static]
Vector3i _001i = new Vector3i(0,0,1) [static]
Vector2i _00i = new Vector2i(0,0) [static]
Vector2 _01 = new Vector2(0.0f,1.0f) [static]
Vector3 _010 = new Vector3(0.0f,1.0f,0.0f) [static]
Vector4 _0100 = new Vector4(0.0f,1.0f,0.0f,0.0f) [static]
Vector4 _0101 = new Vector4(0.0f,1.0f,0.0f,1.0f) [static]
Vector3i _010i = new Vector3i(0,1,0) [static]
Vector3 _011 = new Vector3(0.0f,1.0f,1.0f) [static]
Vector4 _0110 = new Vector4(0.0f,1.0f,1.0f,0.0f) [static]
Vector4 _0111 = new Vector4(0.0f,1.0f,1.0f,1.0f) [static]
Vector3i _011i = new Vector3i(0,1,1) [static]
Vector2i _01i = new Vector2i(0,1) [static]
Vector2 _10 = new Vector2(1.0f,0.0f) [static]
Vector3 _100 = new Vector3(1.0f,0.0f,0.0f) [static]
Vector4 _1000 = new Vector4(1.0f,0.0f,0.0f,0.0f) [static]
Vector4 _1001 = new Vector4(1.0f,0.0f,0.0f,1.0f) [static]
Vector3i _100i = new Vector3i(1,0,0) [static]
Vector3 _101 = new Vector3(1.0f,0.0f,1.0f) [static]
Vector4 _1010 = new Vector4(1.0f,0.0f,1.0f,0.0f) [static]
Vector4 _1011 = new Vector4(1.0f,0.0f,1.0f,1.0f) [static]
Vector3i _101i = new Vector3i(1,0,1) [static]
Vector2i _10i = new Vector2i(1,0) [static]
Vector2 _11 = new Vector2(1.0f,1.0f) [static]
Vector3 _110 = new Vector3(1.0f,1.0f,0.0f) [static]
Vector4 _1100 = new Vector4(1.0f,1.0f,0.0f,0.0f) [static]
Vector4 _1101 = new Vector4(1.0f,1.0f,0.0f,1.0f) [static]
Vector3i _110i = new Vector3i(1,1,0) [static]
Vector3 _111 = new Vector3(1.0f,1.0f,1.0f) [static]
Vector4 _1110 = new Vector4(1.0f,1.0f,1.0f,0.0f) [static]
Vector4 _1111 = new Vector4(1.0f,1.0f,1.0f,1.0f) [static]
Vector3i _111i = new Vector3i(1,1,1) [static]
Vector2i _11i = new Vector2i(1,1) [static]
Vector4 UV_TransformIdentity = new Vector4( 0.0f, 0.0f, 1.0f, 1.0f ) [static]

UV transform stored as (offset, scale) in a Vector4.

offset=0,0 scale=1,1 means identity.


Property Documentation

float HalfPi [static, get]

pi/2

float Pi [static, get]
float TwicePi [static, get]

2pi