Math - Overview

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

Hierarchy of objects in Opus

Functions:

Math.abs

Returns the absolute value of a number

Math.acos

Returns the arccosine of a number (in radians)

Math.asin

Returns the arcsine of a number (in radians)

Math.atan

Returns the arctangent of a number (in radians)

Math.atan2

Returns the angle from the X-axis to a point

Math.ceil

Rounds a number up

Math.cos

Returns the cosine of a number

Math.E

Returns Euler’s constant e (approx. 2.718)

Math.exp

Returns E to the power of the argument passed

Math.floor

Rounds a number down

Math.LN10

Returns the natural log of 10 (approx. 2.303)

Math.log

Returns the natural log (base E) of a number

Math.LOG10E

Returns the base 10 log of E (approx. 0.434)

Math.max

Returns the larger of two values

Math.min

Returns the smaller of two values

Math.PI

Returns PI (approx. 3.1415)

Math.pow

Returns the first parameter raised to the power of the second

Math.random

Returns a pseudo-random number between 0 and 1

Math.round

Rounds to the nearest integer

Math.sin

Returns the sine of a number

Math.sqrt

Returns the square root of a number

Math.SQRT1_2

Returns the square root of ˝ (approx. 0.707)

Math.SQRT2

Returns the square root of 2 (approx. 1.414)

Math.tan

Returns the tangent of a number