Novelty scripting reference > Math functions

Math functions

Mathematical script functions:

abs
acos
cosh
asin
atan
atan2
ceil
clamp
cross
cos
deg
dot
floor
fraction
invert
log10
max
min
pow
rad
rand
randf
sin
sinh
sqrt
tan
tanh
TransformToObjectCoord
TransformToSceneCoord

Constants:

PI
TWOPI


float abs(float value)

Absolute value.


float acos(float value)

Inverse cosine (arccos).


float cosh(float value)

Hyperbolic cosine.


float asin(float value)

Inverse sine (arcsin).


float atan(float value)

Inverse tangent (arctan).


float atan2(float y, float x)

Convert a 2D vector (X, Y) to polar coordinates (angle).


float ceil(float value)

Ceiling function. Returns the smallest integer value greater or equal to value.


int clamp(int value, int min, int max)
float clamp(float value, float min, float max)
double clamp(double value, double min, double max)

Clamp Value between Min and Max.


Vector3@ cross(const Vector3 &in vA, const Vector3 &in vB)

Calculate cross product of two vectors.


float cos(float value)

Cosine.


float deg(float radians)

Convert radians to degrees.

See also:
rad


float dot(const Vector2 &in vA, const Vector2 &in vB)
float dot(const Vector3 &in& vA, const Vector3 &in vB)
float dot(const Vector4 &in& vA, const Vector4 &in vB)

Calculates dot product of two vectors.


float floor(float value)

Floor function. Returns the greatest integer value less or equal to Value.


float fraction(float value)

Returns the fractional part of Value.


float invert(float value)
double invert(double value)

Returns inverted value. (1.0 - Value)


float log10(float value)

Decadic logarithm.


int max(int a, int b)
float max(float a, float b)
double max(double a, double b)

Returns the higher value of A and B.


int min(int a, int b)
float min(float a, float b)
double min(double a, double b)

Returns the lower value of A and B.


float pow(float value, float raise)

Calculate power of a value.


float rad(float degrees)

Convert degrees to radians.

See also:
deg


int rand(int range)

Returns random vlaue between 0 and Range.


float randf()

Returns random value between 0.0f and 1.0f.


float sin(float value)

Sine.


float sinh(float value)

Hyperbolic Sine.


float sqrt(float value)

Calculate square root of Value.


float tan(float value)

Tangent.


float tanh(float value)

Hyperbolic tangent.


Vector2 TransformToObjectCoord(Object@ obj, float x, float y)
Vector2 TransformToObjectCoord(Object@ obj, const Vector2 &in point)

Transforms scene-centric coordinates into object-relative coordinates.
The rotation and scale of the object is included in the transform.


Vector2 TransformToSceneCoord(float x, float y)
Vector2 TransformToSceneCoord(const Vector2 &in point)

Transforms scene-centric coordinates into top-left-relative coordinates.


Constants

const double PI = 3.141592653589793238462643383279
const double TWOPI = 6.283185307179586476925286766559

Back to top