mirror of
https://github.com/photonstorm/phaser
synced 2025-01-12 13:18:49 +00:00
29 lines
592 B
JavaScript
29 lines
592 B
JavaScript
|
|
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;
|