Numbers & Text > Trig / Exponents


Conversion

Degrees <--> Radians

degrees-block

Converts the given number to degrees or radians.

Util.toDegrees([NUMBER])
Util.toRadians([NUMBER])

Constants

Pi

pi-block

Returns the value of Pi (3.14159...).

Math.PI

e

e-block

Returns e, the base of natural logarithms. (2.718...)

2.71828

Trig Functions

Sin / Cos / Tan

trig-block

Returns the result of applying a trigonometric function to the given number. Dropdown for degrees/radians specifies what format the incoming number is in. Supports sin/cos/tan/asin/acos/atan.

//Incoming number is Degrees
Math.sin([NUMBER] * Utils.RAD)

//Incoming number is Radians
Math.sin([NUMBER])

//Other operations
Math.cos([NUMBER])
Math.tan([NUMBER])
Math.asin([NUMBER])
Math.acos([NUMBER])
Math.atan([NUMBER])

Inverse Tangent

inverse-tan-block

Converts from rectangular to polar coordinates. The return value is in radians.

Math.atan2([NUMBER],[NUMBER])

Example: Point Actor Towards Mouse

atan-example

Using inverse tangent, we can calculate the angle to rotate the actor to based on the mouse's position.


Exponents

Square Root

sqrt-block

Returns the square root of the given number.

Math.sqrt[NUMBER]

Power

power-block

Returns the given number to the specified power (e.g., xy).

Math.pow[NUMBER, NUMBER]

Natural Logarithm / e Raised to a Power

log-block

ln - Returns the natural logarithm of the given number.
e^ - Returns the number e to the given power.

Math.log[NUMBER]
Math.exp[NUMBER]