Merge pull request #75 from ngradwohl/feature/math_functions

add some new math functions
This commit is contained in:
Лu Лinveгa 2019-07-23 18:06:19 +12:00 committed by GitHub
commit 0d0ff88fe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -212,6 +212,8 @@ function Library (ronin) {
return Math.round(val / step) * step return Math.round(val / step) * step
} }
this.floor = Math.floor // round down to the nearest integer
this.min = Math.min this.min = Math.min
this.max = Math.max this.max = Math.max
@ -224,6 +226,18 @@ function Library (ronin) {
this.cos = Math.cos this.cos = Math.cos
this.log = Math.log // caclulates on the base of e
this.pow = (a, b) => { // calculates a^b
return Math.pow(a, b)
}
this.sqrt = Math.sqrt // calculate the square root
this.sq = (a) => { // calculate the square
return a * a;
}
this.PI = Math.PI this.PI = Math.PI
this.TWO_PI = Math.PI * 2 this.TWO_PI = Math.PI * 2