Math

private class
system.Math

Description

The Math class is a utility for common mathematical functions in LoomScript.

API overview

Constructor

Math ()

Constants

Constants

E: Number static

A mathematical constant for the base of natural logarithms, expressed as e

LN10: Number static

A mathematical constant for the natural logarithm of 10, expressed as loge10

LN2: Number static

A mathematical constant for the natural logarithm of 2, expressed as loge2

LOG10E: Number static

A mathematical constant for the base-10 logarithm of the constant e (Math.E), expressed as log10e

LOG2E: Number static

A mathematical constant for the base-2 logarithm of the constant e, expressed as log2e

PI: Number static

A mathematical constant for the ratio of the circumference of a circle to its diameter, expressed as pi, with a value of 3.141592653589793

SQRT1_2: Number static

A mathematical constant for the square root of one-half

SQRT2: Number static

A mathematical constant for the square root of 2

TWOPI: Number static

PI * 2

Functions

Public functions

abs ( value: Number ): Number static native

Returns the absolute value for the number specified by the parameter value

acos ( val: Number ): Number static native

Returns the arc cosine of the number specified in the parameter val, in radians

asin ( val: Number ): Number static native

Returns the arc sine for the number specified in the parameter val, in radians

atan ( val: Number ): Number static native

Returns the value, in radians, of the angle whose tangent is specified in the parameter val

atan2 ( y: Number , x: Number ): Number static native

Returns the angle of the point y/x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle)

ceil ( value: Number ): Number static native

Returns a rounded up value of the specified number or expression

clamp ( value: Number , minimum: Number = 0 , maximum: Number = 1 ): Number static

Clamps the value to the specified minimum and maximum values

cos ( value: Number ): Number static native

Returns the cosine of the specified angle in radians

degToRad ( deg: Number ): Number static

Converts the angle provided, in degrees, to its radian representation

exp ( val: Number ): Number static native

Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x

floor ( value: Number ): Number static native

Returns a rounded down value of the number or expression specified in the parameter val

isPowerOf2 ( value: Number ): Boolean static

Checks if the value provided is equal to a Power of 2 Number (ie

log ( val: Number ): Number static native

Returns the natural logarithm of the parameter val

max ( val1: Number , val2: Number , rest: Vector.<Object> ): Number static native

Evaluates val1 and val2 (or more values) and returns the largest value

max2 ( val1: Number , val2: Number ): Number static

Fast path for max of just 2 values

min ( val1: Number , val2: Number , rest: Vector.<Object> ): Number static native

Evaluates val1 and val2 (or more values) and returns the smallest value

min2 ( val1: Number , val2: Number ): Number static

Fast path for min of just 2 values

pow ( base: Number , exponent: Number ): Number static native

Returns base to the power of exponent

radToDeg ( rad: Number ): Number static

Converts the angle provided, in radians, to its degree representation

random (): Number static native

Returns a pseudo-random number n, where 0 <= n <= 1

randomRange ( min: Number , max: Number ): Number static native

Returns a pseudo-random number n, where min <= n <= max

randomRangeInt ( min: Number , max: Number ): Number static native

Returns a pseudo-random integer value n, where min <= n <= max

round ( value: Number ): Number static native

Rounds the value of the parameter value up or down to the nearest integer and returns the value

sin ( value: Number ): Number static native

Returns the sine of the specified angle in radians

sqrt ( value: Number ): Number static native

Returns the square root of the specified number

tan ( value: Number ): Number static native

Returns the tangent of the specified angle

Constructor

Math ()

Constants

E: Number

static

A mathematical constant for the base of natural logarithms, expressed as e.

LN10: Number

static

A mathematical constant for the natural logarithm of 10, expressed as loge10.

LN2: Number

static

A mathematical constant for the natural logarithm of 2, expressed as loge2.

LOG10E: Number

static

A mathematical constant for the base-10 logarithm of the constant e (Math.E), expressed as log10e.

LOG2E: Number

static

A mathematical constant for the base-2 logarithm of the constant e, expressed as log2e.

PI: Number

static

A mathematical constant for the ratio of the circumference of a circle to its diameter, expressed as pi, with a value of 3.141592653589793.

SQRT1_2: Number

static

A mathematical constant for the square root of one-half.

SQRT2: Number

static

A mathematical constant for the square root of 2.

TWOPI: Number

static

PI * 2

Functions

abs ( value: Number ): Number

static native

Returns the absolute value for the number specified by the parameter value.

Parameters

value: Number


acos ( val: Number ): Number

static native

Returns the arc cosine of the number specified in the parameter val, in radians.

Parameters

val: Number


asin ( val: Number ): Number

static native

Returns the arc sine for the number specified in the parameter val, in radians.

Parameters

val: Number


atan ( val: Number ): Number

static native

Returns the value, in radians, of the angle whose tangent is specified in the parameter val.

Parameters

val: Number


atan2 ( y: Number , x: Number ): Number

static native

Returns the angle of the point y/x in radians, when measured counterclockwise from a circle's x axis (where 0,0 represents the center of the circle).

Parameters

y: Number
x: Number


ceil ( value: Number ): Number

static native

Returns a rounded up value of the specified number or expression.

Parameters

value: Number


clamp ( value: Number , minimum: Number = 0 , maximum: Number = 1 ): Number

static

Clamps the value to the specified minimum and maximum values.

Parameters

value: Number
minimum: Number = 0
maximum: Number = 1


cos ( value: Number ): Number

static native

Returns the cosine of the specified angle in radians.

Parameters

value: Number


degToRad ( deg: Number ): Number

static

Converts the angle provided, in degrees, to its radian representation.

Parameters

deg: Number


exp ( val: Number ): Number

static native

Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x.

Parameters

val: Number


floor ( value: Number ): Number

static native

Returns a rounded down value of the number or expression specified in the parameter val.

Parameters

value: Number


getFullTypeName (): String
Inherited from Object

native

Gets the fully qualified type name of the Object. The fully qualified type name includes the package of the type.


Returns

String fully qualified type name of the Object.

getType (): Type
Inherited from Object

native

Gets the Type that describes the Object.


Returns

Type The Type that describes the object.

getTypeName (): String
Inherited from Object

native

Gets the type name of the Object.


Returns

String type name of the Object.

isPowerOf2 ( value: Number ): Boolean

static

Checks if the value provided is equal to a Power of 2 Number (ie. 4, 8, 256, etc.)

Parameters

value: Number


log ( val: Number ): Number

static native

Returns the natural logarithm of the parameter val.

Parameters

val: Number


max ( val1: Number , val2: Number , rest: Vector.<Object> ): Number

static native

Evaluates val1 and val2 (or more values) and returns the largest value.

Parameters

val1: Number
val2: Number
rest: Vector.<Object>


max2 ( val1: Number , val2: Number ): Number

static

Fast path for max of just 2 values.

Parameters

val1: Number
val2: Number


min ( val1: Number , val2: Number , rest: Vector.<Object> ): Number

static native

Evaluates val1 and val2 (or more values) and returns the smallest value.

Parameters

val1: Number
val2: Number
rest: Vector.<Object>


min2 ( val1: Number , val2: Number ): Number

static

Fast path for min of just 2 values.

Parameters

val1: Number
val2: Number


pow ( base: Number , exponent: Number ): Number

static native

Returns base to the power of exponent.

Parameters

base: Number
exponent: Number


radToDeg ( rad: Number ): Number

static

Converts the angle provided, in radians, to its degree representation.

Parameters

rad: Number


random (): Number

static native

Returns a pseudo-random number n, where 0 <= n <= 1.



randomRange ( min: Number , max: Number ): Number

static native

Returns a pseudo-random number n, where min <= n <= max.

Parameters

min: Number
max: Number


randomRangeInt ( min: Number , max: Number ): Number

static native

Returns a pseudo-random integer value n, where min <= n <= max.

Parameters

min: Number
max: Number


round ( value: Number ): Number

static native

Rounds the value of the parameter value up or down to the nearest integer and returns the value.

Parameters

value: Number


sin ( value: Number ): Number

static native

Returns the sine of the specified angle in radians.

Parameters

value: Number


sqrt ( value: Number ): Number

static native

Returns the square root of the specified number.

Parameters

value: Number


tan ( value: Number ): Number

static native

Returns the tangent of the specified angle.

Parameters

value: Number


toString (): String
Inherited from Object

native

Returns a String that describes the Object. This can be overriden to provide extra details when printing objects using trace().


Returns

String String that described the Object.

: