wiki.sine.space | sinespace

Scripting/Server/SMath

From wiki.sine.space
Revision as of 20:33, 23 February 2022 by Voidtech (Talk | contribs)

Jump to: navigation, search

Static Public Member Functions

Random

static float Random ();

Returns a random value from 0 to 1 (inclusive)


RandomRange

static float RandomRange (float min, float max);

Returns a value between min and max, inclusive, randomly.


RandomInteger

static int RandomInteger (int min, int max);

Returns a value between min (inclusive) and max (exclusive).


Abs

static float Abs (float v);

Returns the absolute number (i.e. always positive) of the input value.


Abs

static int Abs (int v);

Returns the absolute number (i.e. always positive) of the input value.


Acos

static float Acos (float v);

Returns the arc cosine of the input value


Approximately

static bool Approximately (float a, float b);

Returns true if the values approximately are equal. Due to the nature of floating point values on modern computers, it is often possible to get two values that should match, which are very close, but not exactly the same.


Asin

static float Asin (float v);

Returns the arc sine value of 'v'


Atan

static float Atan (float v);

Returns the arc tangent value of 'v'


Atan2

static float Atan2 (float y, float x);

Returns the arc tangent of y/x


Ceil

static int Ceil (float v);

Returns the ceil value of 'val' as an integer


Clamp

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

Clamps val between min and max, and returns the result


Clamp01

static float Clamp01 (float v);

Clamps val between 0 and 1, and returns the result


ClosestPowerOfTwo

static int ClosestPowerOfTwo (int v);

Returns the closest power of two to val


Cos

static float Cos (float v);

Returns the cosine of val


DeltaAngle

static float DeltaAngle (float current, float target);

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


Exp

static float Exp (float v);

Returns e raised to v power.


Floor

static int Floor (float v);

Returns floor of val, converted to an int


GammaToLinearSpace

static float GammaToLinearSpace (float v);

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


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)


IsPowerOfTwo

static bool IsPowerOfTwo (int v);

Returns true if val is a power of two


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


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


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)


LinearToGammaSpace

static float LinearToGammaSpace (float v);

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


Log

static float Log (float v);

Returns the natural logarithm for 'v'


Log

static float Log (float v, float p);

Returns the logarithm of 'p' for 'v'


Log10

static float Log10 (float v);

Returns the Log10 value for 'v'


Max

static float Max (float a, float b);

Returns higher of 'a' or 'b'


Min

static float Min (float a, float b);

Returns lower of 'a' or 'b'


MoveTowards

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

Move value to target, but by no more than delta


MoveTowardsAngle

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

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


NextPowerOfTwo

static int NextPowerOfTwo (int v);

Return the next power of two larger or equal to val


PerlinNoise

static float PerlinNoise (float x, float y);

Return 2D Perlin noise for coordinates x and y


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'


Pow

static float Pow (float value, float pow);

Return x raised to y power


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'


Round

static int Round (float value);

Returns the nearest integer value to val


Sign

static float Sign (float value);

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


Sin

static float Sin (float value);

Returns the sine of val


SmoothStep

static float SmoothStep (float edge0, float edge1, float x);

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


Sqrt

static float Sqrt (float value);

Returns the square root of val


Tan

static float Tan (float value);

Returns the tangent value of 'val'


Static Public Attributes

Pi

Returns the value of "Pi" which is 3.14159265358979