Skyline Lua API
Version 1.0 RC1
Lua Script Reference for Skyline Game Engine.
|
#include <LUA_API_Math.h>
Public Member Functions | |
abs () | |
The Math abs function always returns the non-negative number, of a given value. More... | |
acos () | |
The Math acos function returns the inverse cosine of the given value. More... | |
asin () | |
The Math asin function returns the inverse sine of the given value. More... | |
atan () | |
Return the inverse tangent. We can do this by supplying y/x ourselves using math.atan() or we can pass y and x to atan2() to do this for us. The following is a Small Example on how to use this function: More... | |
atan2 () | |
Return the inverse tangent. We can do this by supplying y/x ourselves using math.atan() or we can pass y and x to atan2() to do this for us. The following is a Small Example on how to use this function: More... | |
ceil () | |
The Math ceil function returns the integer no greater than or no less than the given value. More... | |
floor () | |
The Math floor function returns the integer no greater than or no less than the given value. More... | |
cos () | |
The Math cos function returns the cosine number for a given value in radians. More... | |
sin () | |
The Math sin function returns the cosine number for a given value in radians. More... | |
tan () | |
The Math tan function returns the cosine number for a given value in radians. More... | |
cosh () | |
The Math cosh function returns the hyperbolic cosine number for a given value. More... | |
sinh () | |
The Math cosh function returns the hyperbolic sine number for a given value. More... | |
tanh () | |
The Math cosh function returns the hyperbolic tangent[2] number for a given value. More... | |
deg () | |
The Math deg function allows you to convert from radians to degrees. More... | |
rad () | |
The Math deg function allows you to convert from degrees to radians. More... | |
exp () | |
math.exp(myval) returns e (the base of natural logarithms) raised to the power myval. More... | |
log () | |
math.log() returns the inverse of math.exp(). math.exp(1) returns e. More... | |
log10 () | |
The Math abs function returns the base 10 logarithm of a given number. The number must be positive. More... | |
frexp () | |
This is a normalisation function [6]. The math.frexp() function is used to split the number value into a normalized fraction and an exponent. Two values are returned: the first is a value always in the range 1/2 (inclusive) to 1 (exclusive) and the second is an exponent.The number value will be returned in the operation: More... | |
ldexp () | |
The math.ldexp() function takes a normalised number and returns the floating point representation. This is the value multiplied by 2 to the power of the exponent, i.e.: More... | |
huge () | |
math.huge is a constant. It represents +infinity. More... | |
max () | |
The Math max function returns the maximum value from a variable length list of arguments. More... | |
min () | |
The Math min function returns the minimum value from a variable length list of arguments. More... | |
modf () | |
The Math abs function always returns the non-negative number, of a given value. More... | |
pi () | |
This is the constant PI. More... | |
pow () | |
math.pow() raises the first parameter to the power of the second parameter and returns the result. The binary ^ operator performs the same job as math.pow(), i.e. math.pow(x,y) == x^y. More... | |
random () | |
math.random() generates pseudo-random numbers uniformly distributed. Supplying argument alters its behaviour: More... | |
randomseed () | |
The math.randomseed() function sets a seed for the pseudo-random generator: Equal seeds produce equal sequences of numbers. More... | |
sqrt () | |
The Math sqrt function returns the square root of a given number. Only non-negative arguments are allowed. More... | |
skyMath | linearInterp (inputValue, scaleRangeMin, scaleRangeMax, minOut, maxOut) |
skyMath.linearInterp(inputValue, scaleRangeMin, scaleRangeMax, minOut, maxOut ); More... | |
When Working with the Lua Language you will encounter the need to use the math library. For the Purpose of scripting in skyline, we have included a copy of the math library API
Math Functions are accessed by calling math.function().
math::abs | ( | ) |
The Math abs function always returns the non-negative number, of a given value.
The following is a Small Example on how to use this function:
math.abs(-100) : returns 100 math.abs(25.67) : returns 25.67 math.abs(0) : returns 0
math::acos | ( | ) |
The Math acos function returns the inverse cosine of the given value.
The following is a Small Example on how to use this function:
math.acos(1) : returns 0 math.acos(0) : returns 1.5707963267949
math::asin | ( | ) |
The Math asin function returns the inverse sine of the given value.
The following is a Small Example on how to use this function:
math.asin(1) : returns 1.5707963267949 math.asin(0) : returns 0
math::atan | ( | ) |
Return the inverse tangent. We can do this by supplying y/x ourselves using math.atan() or we can pass y and x to atan2() to do this for us.
The following is a Small Example on how to use this function:
c, s = math.cos(0.8), math.sin(0.8) math.atan(s/c) : returns 0.8
math::atan2 | ( | ) |
Return the inverse tangent. We can do this by supplying y/x ourselves using math.atan() or we can pass y and x to atan2() to do this for us.
The following is a Small Example on how to use this function:
c, s = math.cos(0.8), math.sin(0.8) math.atan2(s,c) : returns 0.8
math::ceil | ( | ) |
The Math ceil function returns the integer no greater than or no less than the given value.
The following is a Small Example on how to use this function:
math.ceil(0.5) : returns 1
math::cos | ( | ) |
The Math cos function returns the cosine number for a given value in radians.
The following is a Small Example on how to use this function:
math.cos(math.pi / 4) : returns 0.70710678118655
math::cosh | ( | ) |
The Math cosh function returns the hyperbolic cosine number for a given value.
The following is a Small Example on how to use this function:
math.cosh(1) : returns 1.5430806348152
math::deg | ( | ) |
The Math deg function allows you to convert from radians to degrees.
The following is a Small Example on how to use this function:
math.deg(math.pi) : returns 180 math.deg(math.pi / 2) : returns 90
math::exp | ( | ) |
math.exp(myval) returns e (the base of natural logarithms) raised to the power myval.
The following is a Small Example on how to use this function:
math.exp(0) : returns 1 math.exp(1) : returns 2.718281828459 math.exp(27) : returns 532048240601.8
math::floor | ( | ) |
The Math floor function returns the integer no greater than or no less than the given value.
The following is a Small Example on how to use this function:
math.floor(0.5) : returns 0
math::frexp | ( | ) |
This is a normalisation function [6]. The math.frexp() function is used to split the number value into a normalized fraction and an exponent.
Two values are returned: the first is a value always in the range 1/2 (inclusive) to 1 (exclusive) and the second is an exponent.The number value will be
returned in the operation:
normalized_fraction * 2 ^ exponent
The following is a Small Example on how to use this function:
math.frexp(2) : returns 0.5 2 math.frexp(3) : returns 0.75 2 math.frexp(128) : returns 0.5 8 math.frexp(3.1415927) : returns 0.785398175 2
math::huge | ( | ) |
math.huge is a constant. It represents +infinity.
The following is a Small Example on how to use this function:
math.huge : returns inf math.huge / 2 : returns inf -math.huge : returns -inf math.huge/math.huge : returns nan -- indeterminate math.huge * 0 : returns nan -- indeterminate 1/0 : returns inf (math.huge == math.huge) : returns true (1/0 == math.huge) : returns true
math::ldexp | ( | ) |
The math.ldexp() function takes a normalised number and returns the floating point representation. This is the value multiplied by 2 to the power of the exponent, i.e.:
The following is a Small Example on how to use this function:
math.ldexp(x, exp) == x * 2 ^ exp : returns true math.ldexp(0.785,2) : returns 3.14 math.ldexp(0.5,8) : returns 128
skyMath math::linearInterp | ( | inputValue | , |
scaleRangeMin | , | ||
scaleRangeMax | , | ||
minOut | , | ||
maxOut | |||
) |
skyMath.linearInterp(inputValue, scaleRangeMin, scaleRangeMax, minOut, maxOut );
math::log | ( | ) |
math.log() returns the inverse of math.exp(). math.exp(1) returns e.
The following is a Small Example on how to use this function:
math.log(532048240601) : returns 26.999999999998 math.log(3) : returns 1.0986122886681
math::log10 | ( | ) |
The Math abs function returns the base 10 logarithm of a given number. The number must be positive.
The following is a Small Example on how to use this function:
math.log10(100) : returns 2 math.log10(256) : returns 2.4082399653118 math.log10(-1) : returns nan -- can return -1.#INF on some Windows installs
math::max | ( | ) |
The Math max function returns the maximum value from a variable length list of arguments.
The following is a Small Example on how to use this function:
math.max(1.2, -7, 3) : returns 3 math.max(1.2, 7, 3) : returns 7
Note that some operations on math.huge return a special "not-a-number" value that displays as nan. This is a bit of a misnomer. nan is a number type, though it's different from other numbers:
type(math.huge * 0) : returns number
math::min | ( | ) |
The Math min function returns the minimum value from a variable length list of arguments.
The following is a Small Example on how to use this function:
math.min(1,2) : returns 1 math.min(1.2, 7, 3) : returns 1.2 math.min(1.2, -7, 3) : returns -7
math::modf | ( | ) |
The Math abs function always returns the non-negative number, of a given value.
The following is a Small Example on how to use this function:
math.modf(5) : returns 5 0 math.modf(5.3) : returns 5 0.3 math.modf(-5.3) : returns -5 -0.3
math::pi | ( | ) |
This is the constant PI.
The following is a Small Example on how to use this function:
math.pi : returns 3.1415926535898
math::pow | ( | ) |
math.pow() raises the first parameter to the power of the second parameter and returns the result.
The binary ^ operator performs the same job as math.pow(), i.e. math.pow(x,y) == x^y.
The following is a Small Example on how to use this function:
math.pow(100,0) : returns 1 math.pow(7,2) : returns 49 math.pow(2,8) : returns 256 math.pow(3,2.7) : returns 19.419023519771 5 ^ 2 : returns 25 2^8 : returns 256
math::rad | ( | ) |
The Math deg function allows you to convert from degrees to radians.
The following is a Small Example on how to use this function:
math.rad(180) : 3.1415926535898 math.rad(1) : 0.017453292519943
math::random | ( | ) |
math.random() generates pseudo-random numbers uniformly distributed. Supplying argument alters its behaviour:
math.random() with no arguments generates a real number between 0 and 1.
math.random(upper) generates integer numbers between 1 and upper.
math.random(lower, upper) generates integer numbers between lower and upper.
The following is a Small Example on how to use this function:
math.random() : returns 0.0012512588885159 math.random() : returns 0.56358531449324 math.random(100) : returns 20 math.random(100) : returns 81 math.random(70,80) : returns 76 math.random(70,80) : returns 73
upper and lower must be integer. In other case Lua casts upper into an integer, sometimes giving math.floor(upper) and others math.ceil(upper), with unexpected results (the same for lower).
math::randomseed | ( | ) |
The math.randomseed() function sets a seed for the pseudo-random generator: Equal seeds produce equal sequences of numbers.
The following is a Small Example on how to use this function:
math.randomseed(1234) math.random() : returns 0.12414929654836 math.random() : returns 0.0065004425183874 math.random() : returns 0.3894466994232 math.randomseed(1234) math.random() : returns 0.12414929654836 math.random() : returns 0.0065004425183874 math.random() : returns 0.3894466994232
math::sin | ( | ) |
The Math sin function returns the cosine number for a given value in radians.
The following is a Small Example on how to use this function:
math.sin(0.123) : returns 0.12269009002432
math::sinh | ( | ) |
The Math cosh function returns the hyperbolic sine number for a given value.
The following is a Small Example on how to use this function:
math.sinh(1) : returns 1.1752011936438
math::sqrt | ( | ) |
The Math sqrt function returns the square root of a given number. Only non-negative arguments are allowed.
The following is a Small Example on how to use this function:
math.sqrt(100) : returns 10 math.sqrt(1234) : returns 35.128336140501 math.sqrt(-7) : returns -1.#IND
math::tan | ( | ) |
The Math tan function returns the cosine number for a given value in radians.
The following is a Small Example on how to use this function:
math.tan(5/4) : returns 3.0095696738628 math.tan(.77) : returns 0.96966832796149
math::tanh | ( | ) |
The Math cosh function returns the hyperbolic tangent[2] number for a given value.
The following is a Small Example on how to use this function:
math.tanh(1) : returns 0.76159415595576