SMath

Index

Static Functions Index

Function Name

static float Random ()

static float RandomRange (float min, float max)

static int RandomInteger (int min, int max)

static float Abs (float v) static int Abs (int v)

static float Acos (float v)

static bool Approximately (float a, float b)

static float Asin (float v)

static float Atan (float v)

static float Atan2 (float y, float x)

static int Ceil (float v)

static float Clamp (float v, float min, float max)

static float Clamp01 (float v)

static int ClosestPowerOfTwo (int v)

static float Cos (float v)

static float DeltaAngle (float current, float target)

static float Exp (float v)

static int Floor (float v)

static float GammaToLinearSpace (float v)

static float InverseLerp (float a, float b, float value)

static bool IsPowerOfTwo (int v)

static float Lerp (float a, float b, float v)

static float LerpAngle (float a, float b, float v)

static float LerpUnclamped (float a, float b, float v)

static float LinearToGammaSpace (float v)

static float Log (float v) static float Log (float v, float p)

static float Log10 (float v)

static float Max (float a, float b)

static float Min (float a, float b)

static float MoveTowards (float value, float target, float delta)

static float MoveTowardsAngle (float value, float target, float delta)

static int NextPowerOfTwo (int v)

static float PerlinNoise (float x, float y)

static float PingPong (float t, float length)

static float Pow (float value, float pow)

static float Repeat (float value, float length)

static int Round (float value)

static float Sign (float value)

static float Sin (float value)

static float SmoothStep (float from, float to, float t)

static float Sqrt (float value)

static float Tan (float value)

Static Attributes Index

Property Name

static readonly float Pi****

Static Functions

Random

static float Random ()

Returns a random float between 0 and 1 (inclusive)

RandomRange

static float RandomRange (float min, float max)

Returns a random float between min and max (inclusive)

Parameter
Type
Description

RandomInteger

static int RandomInteger (int min, int max)

Returns a random float between min (inclusive) and max (exclusive)

Parameter
Type
Description

Abs

static float Abs (float v) static int Abs (int v)

Returns the absolute value of 'val'

Parameter
Type
Description

Acos

static float Acos (float v)

Returns the arc cosine value of 'val'

Parameter
Type
Description

Approximately

static bool Approximately (float a, float b)

True if the difference between a and b is less than epsilon

Parameter
Type
Description

Asin

static float Asin (float v)

Returns the arc sine value of 'val'

Parameter
Type
Description

Atan

static float Atan (float v)

Returns the arc tangent value of 'val'

Parameter
Type
Description

Atan2

static float Atan2 (float y, float x)

Returns the arc tangent of y/x

Parameter
Type
Description

Ceil

static int Ceil (float v)

Returns the ceil value of 'val' as an integer

Parameter
Type
Description

Clamp

static float Clamp (float v, float min, float max)

Clamps val between min and max, and returns the result

Parameter
Type
Description

Clamp01

static float Clamp01 (float v)

Clamps val between 0 and 1, and returns the result

Parameter
Type
Description

ClosestPowerOfTwo

static int ClosestPowerOfTwo (int v)

Returns the closest power of two to val

Parameter
Type
Description

Cos

static float Cos (float v)

Returns the cosine of val

Parameter
Type
Description

DeltaAngle

static float DeltaAngle (float current, float target)

_Returns the difference in degrees between two values (e.g. 350' and 17' returns 27') _

Parameter
Type
Description

Exp

static float Exp (float v)

Returns e raised to val power.

Parameter
Type
Description

Floor

static int Floor (float v)

Returns floor of val, converted to an int

Parameter
Type
Description

GammaToLinearSpace

static float GammaToLinearSpace (float v)

Converts a colour value from Gamma to Linear Space (Pow 2.2)

Parameter
Type
Description

InverseLerp

static float InverseLerp (float a, float b, float value)

Returns the percentage between a and b that 'val' is on a line (opposite of Lerp)

Parameter
Type
Description

IsPowerOfTwo

static bool IsPowerOfTwo (int v)

Returns true if val is a power of two

Parameter
Type
Description

Lerp

static float Lerp (float a, float b, float v)

Interpolates between 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1

Parameter
Type
Description

LerpAngle

static float LerpAngle (float a, float b, float v)

Interpolates between angles 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1

Parameter
Type
Description

LerpUnclamped

static float LerpUnclamped (float a, float b, float v)

Interpolates between 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1, but unbounded (allowing higher/lower values)

Parameter
Type
Description

LinearToGammaSpace

static float LinearToGammaSpace (float v)

Converts a colour value from Linear to Gamma Space (Pow 1/2.2)

Parameter
Type
Description

Log

static float Log (float v) static float Log (float v, float p)

Returns the natural logarithm for 'val'

Parameter
Type
Description

Log10

static float Log10 (float v)

Returns the Log10 value for 'val'

Parameter
Type
Description

Max

static float Max (float a, float b)

Returns higher of 'a' or 'b'

Parameter
Type
Description

Min

static float Min (float a, float b)

Returns lower of 'a' or 'b'

Parameter
Type
Description

MoveTowards

static float MoveTowards (float value, float target, float delta)

Move value to target, but by no more than delta

Parameter
Type
Description

MoveTowardsAngle

static float MoveTowardsAngle (float value, float target, float delta)

Move angle value to target, but by no more than delta

Parameter
Type
Description

NextPowerOfTwo

static int NextPowerOfTwo (int v)

Return the next power of two larger or equal to val

Parameter
Type
Description

PerlinNoise

static float PerlinNoise (float x, float y)

Return 2D Perlin noise for coordinates x and y

Parameter
Type
Description

PingPong

static float PingPong (float t, float length)

Return a value between 0 and length that oscillates upwards and back based on the position of 'val'

Parameter
Type
Description

Pow

static float Pow (float value, float pow)

Return x raised to y power

Parameter
Type
Description

Repeat

static float Repeat (float value, float length)

Return a value between 0 and length that returns to 0 after exceeding length based on 'val'

Parameter
Type
Description

Round

static int Round (float value)

Returns the nearest integer value to val

Parameter
Type
Description

Sign

static float Sign (float value)

Returns either 1 or -1 based on the sign of 'val'

Parameter
Type
Description

Sin

static float Sin (float value)

Returns the sine of val

Parameter
Type
Description

SmoothStep

static float SmoothStep (float from, float to, float t)

Similar to Lerp but moves slowly closer to the edges ('Spherical Lerp')

Parameter
Type
Description

Sqrt

static float Sqrt (float value)

Returns the square root of val

Parameter
Type
Description

Tan

static float Tan (float value)

Returns the tangent value of 'val'

Parameter
Type
Description

Static Attributes

Pi

static readonly float Pi = 3.14159265358979f

Returns the constant value of Π.