Update index.js
This commit is contained in:
parent
5744fa3c22
commit
a80c3334a3
1 changed files with 16 additions and 1 deletions
17
index.js
17
index.js
|
@ -1,4 +1,5 @@
|
||||||
function fastInverseSqrt(number) {
|
//fast inverse sqrt
|
||||||
|
function fisqrt(number) {
|
||||||
const threehalfs = 1.5;
|
const threehalfs = 1.5;
|
||||||
const x2 = number * 0.5;
|
const x2 = number * 0.5;
|
||||||
let i = new Float32Array(1);
|
let i = new Float32Array(1);
|
||||||
|
@ -11,3 +12,17 @@ function fastInverseSqrt(number) {
|
||||||
y = Math.round(y * 100) / 100;
|
y = Math.round(y * 100) / 100;
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//manual sqrt
|
||||||
|
function msqrt(number) {
|
||||||
|
for (var i = 0; i * i <= number; i++) {
|
||||||
|
if (i * i === number)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
//square
|
||||||
|
function sq(number) {
|
||||||
|
return number * number;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue