FTrig is a utility for fast approximate trigonometric calculating on javascript, based on this article. FTrig can be used with Node.js, RequireJS or directly in the browser.
A FTrig instance is create as:
var trig = new FTrig(FTrig.LOW); // faster, less accurate
// or
var trig = new FTrig(FTrig.HIGH); // more, more accurate
trig.sin(Math.PI/4);
trig.cos(Math.PI/4);
A FTrig instance provides 2 functions: sin
and cos
, as alias of the 4 main functions:
sinLow
, cosLow
for FTrig.Low
and sinHigh
, cosHigh
for FTrig.High
.
The source is available for download by cloning. Alternatively, you can install via:
Usage:
<script type="text/javascript" src="FTrig.js"></script>
<script type="text/javascript">
var trig = new FTrig(FTrig.LOW);
trig.sin(Math.PI/4);
</script>