Path: /sdk/add_on/scriptmath/
This add-on registers the math functions from the standard C runtime library with the script engine. Use RegisterScriptMath(asIScriptEngine*) to perform the registration.
By defining the preprocessor word AS_USE_FLOAT=0, the functions will be registered to take and return doubles instead of floats.
The function RegisterScriptMathComplex(asIScriptEngine*) registers a type that represents a complex number, i.e. a number with real and imaginary parts.
// Trigonometric functions float cos(float rad); float sin(float rad); float tan(float rad);
// Inverse trigonometric functions float acos(float val); float asin(float val); float atan(float val); float atan2(float y, float x);
// Hyperbolic functions float cosh(float rad); float sinh(float rad); float tanh(float rad);
// Logarithmic functions float log(float val); float log10(float val);
// Power to float pow(float val, float exp);
// Square root float sqrt(float val);
// Absolute value float abs(float val);
// Ceil and floor functions float ceil(float val); float floor(float val);
// Returns the fraction float fraction(float val);
// Approximate float comparison, to deal with numeric imprecision bool closeTo(float a, float b, float epsilon = 0.00001f); bool closeTo(double a, double b, double epsilon = 0.0000000001);
// Conversion between floating point and IEEE 754 representations float fpFromIEEE(uint raw); double fpFromIEEE(uint64 raw); uint fpToIEEE(float fp); uint64 fpToIEEE(double fp);
// This type represents a complex number with real and imaginary parts
class complex
{
// Constructors
complex();
complex(const complex &in);
complex(float r);
complex(float r, float i); // Equality operator
bool opEquals(const complex &in) const; // Compound assignment operators
complex &opAddAssign(const complex &in);
complex &opSubAssign(const complex &in);
complex &opMulAssign(const complex &in);
complex &opDivAssign(const complex &in); // Math operators
complex opAdd(const complex &in) const;
complex opSub(const complex &in) const;
complex opMul(const complex &in) const;
complex opDiv(const complex &in) const; // Returns the absolute value (magnitude)
float abs() const; // Swizzle operators
complex get_ri() const;
void set_ri(const complex &in);
complex get_ir() const;
void set_ir(const complex &in); // The real and imaginary parts
float r;
float i;
}