OmegaEngine API  1.0.3
Static Public Member Functions | List of all members
OmegaEngine.MathUtils Class Reference

Designed to keep other code clean of messy spaghetti code required for some math operations. More...

Static Public Member Functions

static decimal Clamp (this decimal value, decimal min=0, decimal max=1)
 Makes a value stay within a certain range More...
 
static double Clamp (this double value, double min=0, double max=1)
 Makes a value stay within a certain range More...
 
static float Clamp (this float value, float min=0, float max=1)
 Makes a value stay within a certain range More...
 
static int Clamp (this int value, int min=0, int max=1)
 Makes a value stay within a certain range More...
 
static double Modulo (this double dividend, double divisor)
 Calculates a modulus (always positive). More...
 
static float Modulo (this float dividend, float divisor)
 Calculates a modulus (always positive). More...
 
static int Modulo (this int dividend, int divisor)
 Calculates a modulus (always positive). More...
 
static float DegreeToRadian (this float value)
 Converts an angle in degrees to radians More...
 
static double DegreeToRadian (this double value)
 Converts an angle in degrees to radians More...
 
static float RadianToDegree (this float value)
 Converts an angle in radians to degrees More...
 
static double RadianToDegree (this double value)
 Converts an angle in radians to degrees More...
 
static Vector3 UnitVector (double inclination, double azimuth)
 Calculates a unit vector using spherical coordinates. More...
 
static byte AngleToByte (this double angle)
 Maps a 0�-180� angle in radians to a 0-255 byte value. More...
 
static double ByteToAngle (this byte b)
 Maps a 0-255 byte value to a 0�-180� angle in radians. More...
 
static Vector4 ByteToAngle (this ByteVector4 vector)
 Maps a vector of 0-255 byte values to a vector of 0�-180� angles in radians. More...
 
static double InterpolateTrigonometric (double factor, [NotNull] params double[] values)
 Performs smooth (trigonometric) interpolation between two or more values More...
 
static float InterpolateTrigonometric (this float factor, [NotNull] params float[] values)
 Performs smooth (trigonometric) interpolation between two or more values More...
 
static Vector4 InterpolateTrigonometric (float factor, [NotNull] params Vector4[] values)
 Performs smooth (trigonometric) interpolation between two or more values More...
 
static double Factorial (int n)
 Calculates the factorial of n (n!) More...
 
static double BinomCoeff (int n, int k)
 Calculates the binomial coefficient (n choose k) More...
 
static Vector2 [] Bezier (int resolution, [NotNull] params Vector2[] controlPoints)
 Calculates points on a 2D bezier curve More...
 
static DoubleVector3 [] Bezier (int resolution, [NotNull] params DoubleVector3[] controlPoints)
 Calculates points on a 3D bezier curve More...
 
static double [] GaussKernel (double sigma, int kernelSize)
 Generates a Gaussian kernel. More...
 
static short LoWord (uint l)
 
static short LoWord (int l)
 
static short HiWord (uint l)
 
static short HiWord (int l)
 
static int HiByte (byte b)
 
static int LoByte (byte b)
 
static byte CombineHiLoByte (int high, int low)
 
static Quaternion ViewQuaternion (this Vector3 view, float roll)
 Calculates a rotation quaternion for a view vector More...
 
static Vector2 Rotate (this Vector2 value, float rotation)
 Rotates a Vector2 by rotation around the origin. More...
 
static BoundingBox Transform (this BoundingBox box, Matrix matrix)
 Applies a matrix transform to a bounding box. More...
 
static BoundingSphere Transform (this BoundingSphere sphere, Matrix matrix)
 Applies a matrix transform to a bounding sphere. More...
 

Detailed Description

Designed to keep other code clean of messy spaghetti code required for some math operations.

Member Function Documentation

◆ AngleToByte()

static byte OmegaEngine.MathUtils.AngleToByte ( this double  angle)
static

Maps a 0�-180� angle in radians to a 0-255 byte value.

◆ Bezier() [1/2]

static Vector2 [] OmegaEngine.MathUtils.Bezier ( int  resolution,
[NotNull] params Vector2 []  controlPoints 
)
inlinestatic

Calculates points on a 2D bezier curve

Parameters
controlPointsAn array of control points; the curve will pass through the first and the last entry
resolutionThe desired number of output points
Returns
An array of resolution points on the curve

◆ Bezier() [2/2]

static DoubleVector3 [] OmegaEngine.MathUtils.Bezier ( int  resolution,
[NotNull] params DoubleVector3 []  controlPoints 
)
inlinestatic

Calculates points on a 3D bezier curve

Parameters
resolutionThe desired number of output points
controlPointsAn array of control points; the curve will pass through the first and the last entry
Returns
An array of resolution points on the curve

◆ BinomCoeff()

static double OmegaEngine.MathUtils.BinomCoeff ( int  n,
int  k 
)
inlinestatic

Calculates the binomial coefficient (n choose k)

Parameters
nA value between 0 and 32768
kAn integer

◆ ByteToAngle() [1/2]

static double OmegaEngine.MathUtils.ByteToAngle ( this byte  b)
static

Maps a 0-255 byte value to a 0�-180� angle in radians.

◆ ByteToAngle() [2/2]

static Vector4 OmegaEngine.MathUtils.ByteToAngle ( this ByteVector4  vector)
static

Maps a vector of 0-255 byte values to a vector of 0�-180� angles in radians.

◆ Clamp() [1/4]

static decimal OmegaEngine.MathUtils.Clamp ( this decimal  value,
decimal  min = 0,
decimal  max = 1 
)
inlinestatic

Makes a value stay within a certain range

Parameters
valueThe number to clamp
minThe minimum number to return
maxThe maximum number to return
Returns
The value if it was in range, otherwise min or max .

◆ Clamp() [2/4]

static double OmegaEngine.MathUtils.Clamp ( this double  value,
double  min = 0,
double  max = 1 
)
inlinestatic

Makes a value stay within a certain range

Parameters
valueThe number to clamp
minThe minimum number to return
maxThe maximum number to return
Returns
The value if it was in range, otherwise min or max .

◆ Clamp() [3/4]

static float OmegaEngine.MathUtils.Clamp ( this float  value,
float  min = 0,
float  max = 1 
)
inlinestatic

Makes a value stay within a certain range

Parameters
valueThe number to clamp
minThe minimum number to return
maxThe maximum number to return
Returns
The value if it was in range, otherwise min or max .

◆ Clamp() [4/4]

static int OmegaEngine.MathUtils.Clamp ( this int  value,
int  min = 0,
int  max = 1 
)
inlinestatic

Makes a value stay within a certain range

Parameters
valueThe number to clamp
minThe minimum number to return
maxThe maximum number to return
Returns
The value if it was in range, otherwise min or max .

◆ DegreeToRadian() [1/2]

static float OmegaEngine.MathUtils.DegreeToRadian ( this float  value)
static

Converts an angle in degrees to radians

Parameters
valueThe angle in degrees
Returns
The angle in radians

◆ DegreeToRadian() [2/2]

static double OmegaEngine.MathUtils.DegreeToRadian ( this double  value)
static

Converts an angle in degrees to radians

Parameters
valueThe angle in degrees
Returns
The angle in radians

◆ Factorial()

static double OmegaEngine.MathUtils.Factorial ( int  n)
inlinestatic

Calculates the factorial of n (n!)

Parameters
nA value between 0 and 32768

Values between n=0 and n=16 have been pre-calculated and are therefor very fast

◆ GaussKernel()

static double [] OmegaEngine.MathUtils.GaussKernel ( double  sigma,
int  kernelSize 
)
inlinestatic

Generates a Gaussian kernel.

Parameters
sigmaThe standard deviation of the Gaussian distribution.
kernelSizeThe size of the kernel. Should be an uneven number.

◆ InterpolateTrigonometric() [1/3]

static double OmegaEngine.MathUtils.InterpolateTrigonometric ( double  factor,
[NotNull] params double []  values 
)
inlinestatic

Performs smooth (trigonometric) interpolation between two or more values

Parameters
factorA factor between 0 and values .Length
valuesThe value checkpoints

◆ InterpolateTrigonometric() [2/3]

static float OmegaEngine.MathUtils.InterpolateTrigonometric ( this float  factor,
[NotNull] params float []  values 
)
inlinestatic

Performs smooth (trigonometric) interpolation between two or more values

Parameters
factorA factor between 0 and values .Length
valuesThe value checkpoints

◆ InterpolateTrigonometric() [3/3]

static Vector4 OmegaEngine.MathUtils.InterpolateTrigonometric ( float  factor,
[NotNull] params Vector4 []  values 
)
inlinestatic

Performs smooth (trigonometric) interpolation between two or more values

Parameters
factorA factor between 0 and values .Length
valuesThe value checkpoints

◆ Modulo() [1/3]

static double OmegaEngine.MathUtils.Modulo ( this double  dividend,
double  divisor 
)
inlinestatic

Calculates a modulus (always positive).

◆ Modulo() [2/3]

static float OmegaEngine.MathUtils.Modulo ( this float  dividend,
float  divisor 
)
inlinestatic

Calculates a modulus (always positive).

◆ Modulo() [3/3]

static int OmegaEngine.MathUtils.Modulo ( this int  dividend,
int  divisor 
)
inlinestatic

Calculates a modulus (always positive).

◆ RadianToDegree() [1/2]

static float OmegaEngine.MathUtils.RadianToDegree ( this float  value)
static

Converts an angle in radians to degrees

Parameters
valueThe angle in radians
Returns
The angle in degrees

◆ RadianToDegree() [2/2]

static double OmegaEngine.MathUtils.RadianToDegree ( this double  value)
static

Converts an angle in radians to degrees

Parameters
valueThe angle in radians
Returns
The angle in degrees

◆ Rotate()

static Vector2 OmegaEngine.MathUtils.Rotate ( this Vector2  value,
float  rotation 
)
inlinestatic

Rotates a Vector2 by rotation around the origin.

Parameters
valueThe original vector.
rotationThe angle to rotate by in degrees.
Returns
The rotated Vector2.

◆ Transform() [1/2]

static BoundingBox OmegaEngine.MathUtils.Transform ( this BoundingBox  box,
Matrix  matrix 
)
inlinestatic

Applies a matrix transform to a bounding box.

Parameters
boxThe bounding box to apply the transform to.
matrixThe transformation matrix to apply.
Returns
The transformed bounding box.

◆ Transform() [2/2]

static BoundingSphere OmegaEngine.MathUtils.Transform ( this BoundingSphere  sphere,
Matrix  matrix 
)
inlinestatic

Applies a matrix transform to a bounding sphere.

Parameters
sphereThe bounding sphere to apply the transform to.
matrixThe transformation matrix to apply.
Returns
The transformed bounding sphere.

◆ UnitVector()

static Vector3 OmegaEngine.MathUtils.UnitVector ( double  inclination,
double  azimuth 
)
static

Calculates a unit vector using spherical coordinates.

Parameters
inclinationAngle away from positive Z axis in radians. Values from 0 to Pi.
azimuthAngle away from from positive X axis in radians. Values from 0 to 2*Pi.

◆ ViewQuaternion()

static Quaternion OmegaEngine.MathUtils.ViewQuaternion ( this Vector3  view,
float  roll 
)
static

Calculates a rotation quaternion for a view vector

Parameters
viewThe view vector
rollThe roll value
Returns
A normalized quaternion

The documentation for this class was generated from the following file: