The Math object allows you to perform a variety of scientific calculations in your script including functions for logarithms, trigonometry and geometry.
The functions listed below are all part of the Math object and are either (i) Math constants, such as PI; (ii) or Math methods, such as acos. This means that in the script they must be typed in as follows:
Math.functionName
This means, type the word Math followed by the name of one of the OpusScript functions listed below separated by a full stop, For example:
var myMath = Math.PI
var myMath = Math.acos(-0.01234)
Note:
Some of the Math functions have a constant value, such as, Math.PI because the value of Pi never changes. Other Math functions will evaluate an answer based on parameters you enter, such as, the Math.acos function – see Math examples for more information.
Hierarchy:
Only the specific functions listed under the Functions: heading below can be used with Math objects:
Class Hierarchy:
Math
Functions:
Returns the absolute value of a number | |
Returns the arccosine of a number (in radians) | |
Returns the arcsine of a number (in radians) | |
Returns the arctangent of a number (in radians) | |
Returns the angle from the X-axis to a point | |
Rounds a number up | |
Returns the cosine of a number | |
Returns Euler’s constant e (approx. 2.718) | |
Returns E to the power of the argument passed | |
Rounds a number down | |
Returns the natural log of 10 (approx. 2.303) | |
Returns the natural log (base E) of a number | |
Returns the base 10 log of E (approx. 0.434) | |
Returns the larger of two values | |
Returns the smaller of two values | |
Returns PI (approx. 3.1415) | |
Returns the first parameter raised to the power of the second | |
Returns a pseudo-random number between 0 and 1 | |
Rounds to the nearest integer | |
Returns the sine of a number | |
Returns the square root of a number | |
Returns the square root of ˝ (approx. 0.707) | |
Returns the square root of 2 (approx. 1.414) | |
Returns the tangent of a number |