forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSinCosTableGenerator.js
More file actions
42 lines (35 loc) · 893 Bytes
/
Copy pathSinCosTableGenerator.js
File metadata and controls
42 lines (35 loc) · 893 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* [description]
*
* @function Phaser.Math.SinCosTableGenerator
* @since 3.0.0
*
* @param {number} length - [description]
* @param {number} sinAmp - [description]
* @param {number} cosAmp - [description]
* @param {number} frequency - [description]
*
* @return {object} [description]
*/
var SinCosTableGenerator = function (length, sinAmp, cosAmp, frequency)
{
if (sinAmp === undefined) { sinAmp = 1; }
if (cosAmp === undefined) { cosAmp = 1; }
if (frequency === undefined) { frequency = 1; }
frequency *= Math.PI / length;
var cos = [];
var sin = [];
for (var c = 0; c < length; c++)
{
cosAmp -= sinAmp * frequency;
sinAmp += cosAmp * frequency;
cos[c] = cosAmp;
sin[c] = sinAmp;
}
return {
sin: sin,
cos: cos,
length: length
};
};
module.exports = SinCosTableGenerator;