Ashasekayi (Talk | contribs) |
Ashasekayi (Talk | contribs) |
||
Line 8: | Line 8: | ||
{{ScriptFunction|float|Abs|(float val);|Returns the absolute value of 'val'|5=local value = -4.2<br>local absoluteNum = Space.Math.Abs(value);<br>Space.Log(absoluteNum);<br>-- prints 4 [BUG] should be 4.2}} | {{ScriptFunction|float|Abs|(float val);|Returns the absolute value of 'val'|5=local value = -4.2<br>local absoluteNum = Space.Math.Abs(value);<br>Space.Log(absoluteNum);<br>-- prints 4 [BUG] should be 4.2}} | ||
{{ScriptFunction|int|Abs|(int val);|Returns the absolute value of 'val'|5=local value = -4<br>local absoluteNum = Space.Math.Abs(value);<br>Space.Log(absoluteNum);<br>-- prints 4}} | {{ScriptFunction|int|Abs|(int val);|Returns the absolute value of 'val'|5=local value = -4<br>local absoluteNum = Space.Math.Abs(value);<br>Space.Log(absoluteNum);<br>-- prints 4}} | ||
− | {{ScriptFunction|float|Acos|(float val);|Returns the arc cosine value of 'val'|5=local angle = 0.5;<br>local arcCosine = Space.Math.Acos(angle);<br>Space.Log( | + | {{ScriptFunction|float|Acos|(float val);|Returns the arc cosine value of 'val'|5=local angle = 0.5;<br>local arcCosine = Space.Math.Acos(angle);<br>Space.Log(arcCosine);<br>-- prints 1.04719758033752 (radians) which is 60 degrees}} |
{{ScriptFunction|bool|Approximately|(float a, float b);|True if the difference between a and b is less than epsilon|5=local a = 5.0;<br>local b = 5;<br>local approx1 = Space.Math.Approximately(a, b);<br>Space.Log(approx1);<br>-- prints true<br><br>local a = 5.01;<br>local b = 5.0;<br>local approx2 = Space.Math.Approximately(a, b);<br>Space.Log(approx2);<br>-- prints false<br><br>local a = 5.01;<br>local b = 5.0;<br>local approx3 = Space.Math.Approximately(a, b);<br>Space.Log(approx3);<br>-- prints false}} | {{ScriptFunction|bool|Approximately|(float a, float b);|True if the difference between a and b is less than epsilon|5=local a = 5.0;<br>local b = 5;<br>local approx1 = Space.Math.Approximately(a, b);<br>Space.Log(approx1);<br>-- prints true<br><br>local a = 5.01;<br>local b = 5.0;<br>local approx2 = Space.Math.Approximately(a, b);<br>Space.Log(approx2);<br>-- prints false<br><br>local a = 5.01;<br>local b = 5.0;<br>local approx3 = Space.Math.Approximately(a, b);<br>Space.Log(approx3);<br>-- prints false}} | ||
{{ScriptFunction|bool|Asin|(float val);|Returns the arc sine value of 'val'}} | {{ScriptFunction|bool|Asin|(float val);|Returns the arc sine value of 'val'}} |
The SMath class contains common math functions, see also SVector and SQuaternion for Vector and Quaternion related math functions.
Returns a random float between 0 and 1 (inclusive)
Returns a random float between min and max (inclusive)
Returns a random float between min (inclusive) and max (exclusive)
Returns the absolute value of 'val'
Returns the absolute value of 'val'
Returns the arc cosine value of 'val'
True if the difference between a and b is less than epsilon
Returns the arc sine value of 'val'
Returns the arc tangent value of 'val'
Returns the arc tangent of y/x
Returns the ceil value of 'val' as an integer
Clamps val between min and max, and returns the result
Clamps val between 0 and 1, and returns the result
Returns the closest power of two to val
Returns the cosine of val
Returns the difference in degrees between two values (e.g. 350' and 17' returns 27')
Returns Exp of val
Returns floor of val, converted to an int
Converts a colour value from Gamma to Linear Space (Pow 2.2)
Returns the percentage between a and b that 'val' is on a line (opposite of Lerp)
Returns true if val is a power of two
Interpolates between 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1
Interpolates between angles 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1
Interpolates between 'a' and 'b' based on 'val', assuming 'val' is between 0 and 1, but unbounded (allowing higher/lower values)
Converts a colour value from Linear to Gamma Space (Pow 1/2.2)
Returns the natural logarithm for 'val'
Returns the logarithm of 'p' for 'val'
Returns the Log10 value for 'val'
Returns higher of 'a' or 'b'
Returns lower of 'a' or 'b'
Move value to target, but by no more than delta
Move angle value to target, but by no more than delta
Return the next power of two larger or equal to val
Return 2D Perlin noise for coordinates x and y
Return a value between 0 and length that oscillates upwards and back based on the position of 'val'
Return x raised to y power
Return a value between 0 and length that returns to 0 after exceeding length based on 'val'
Returns the nearest integer value to val
Returns either 1 or -1 based on the sign of 'val'
Returns the sine of val
Similar to Lerp but moves slowly closer to the edges ('Spherical Lerp')
Returns the square root of val
Returns the tangent value of 'val'
|