Math

math : object

Useful namespace for helping with Math utility functions including numerical, 3d, etc.

Kind: global namespace

math.roundTo(val, decimal) ⇒ number

Rounds the inputted val to the nearest decimal place as denoted by the decimal parameter.

Kind: static method of math
Returns: number - - The rounded number to the requested decimal amount.

Param Type Description
val number The number to be rounded.
decimal number The decimal place targeted in the rounding.

Example

For example: roundTo(832.456, 10) = 832.4; roundTo(832.456, 1000) = 832.456; roundTo(832.456, 0.01) = 800;

math.roundVectorTo(vector, decimal)

Rounds the inputted vector to the nearest decimal place as denoted by the decimal parameter.

Kind: static method of math

Param Type Description
vector vector The vector of numbers to be rounded.
decimal number The decimal place targeted in the rounding.

Example

For example: roundTo(<832.456, 92.10003, 23452.1>, 10) = <832.4, 92.1, 2342.1>;

math.radToDeg(val) ⇒ number

Performs the radian To Degree calculation commonly used in math. https://en.wikipedia.org/wiki/Degree_(angle) https://en.wikipedia.org/wiki/Radian

Kind: static method of math
Returns: number - - the calculated degree representation of val.

Param Type Description
val number The number to be converted from radians to degrees

math.computeBoundingSphere(group, relativeTo) ⇒ THREE.Sphere

Computes the bounding sphere of an inputted three group object.

Kind: static method of math
Returns: THREE.Sphere - - the resolved bounding sphere

Param Type Description
group THREE.group the group to be enclosed in the bounding sphere.
relativeTo THREE.group object that the group is relative to. For example if the group is an apple held in a character’s hand, relativeTo would be the characters hand. When left as null, the bounding sphere defaults to the inputted groups original world matrix.