Math
object
math : Useful namespace for helping with Math utility functions including numerical, 3d, etc.
Kind: global namespace
- math :
object
- .roundTo(val, decimal) ⇒
number
- .roundVectorTo(vector, decimal)
- .radToDeg(val) ⇒
number
- .computeBoundingSphere(group, relativeTo) ⇒
THREE.Sphere
- .roundTo(val, decimal) ⇒
number
math.roundTo(val, decimal) ⇒ 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
: roundTo(832.456, 10) = 832.4; roundTo(832.456, 1000) = 832.456; roundTo(832.456, 0.01) = 800; For example
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
: roundTo(<832.456, 92.10003, 23452.1>, 10) = <832.4, 92.1, 2342.1>; For example
number
math.radToDeg(val) ⇒ 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 |
THREE.Sphere
math.computeBoundingSphere(group, relativeTo) ⇒ 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. |