UNPKG

trigfills

Version:

Sin, cos, tan, asin, acos and atan filled for cross browser consistency.

1 lines 1.82 kB
var trigfillfactory=function(){return function(){"use strict";function t(){return"0.9.2"}function n(t,n){return t-Math.floor(t/n)*n}function e(t,n){return t-Math.floor(t/n+.5)*n}function a(t){var n=t*t*t;return t-n*P+n*t*t*x-n*n*t*y+n*n*n*g}function r(t){var n=t*t,e=n*n;return 1-.5*n+e*q-n*e*b+e*e*T}function f(t){return t-=Math.floor(t/M)*M,d>t?(t>=l&&(t=d-t),t>m?r(l-t):a(t)):(t-=d,t>=l&&(t=d-t),t>m?-0-r(l-t):-0-a(t))}function o(t){return f(l-t)}function i(t){var n=1,e=0,a=0;0>t&&(n=0,t=0-t),t>1&&(t=1/t,e=1),t>.26794919&&(t=(I*t-1)/(I+t),a=1);var r=t*t,f=r*r,o=f*f;return t=t-t*r*j+f*t*k-f*r*t*w+o*t*z-o*r*t*A,a&&(t+=l*p),e&&(t=l-t),n?t:-t}function u(t){var e=1,a=0,r=0;t=.9999999999999999*n(t,d),t>l&&(e=0,t=d-t),t>m&&(a=1,t=l-t),t>v&&(r=2,t=.5*t);var f=t*t*t,o=f*f;return t=t+f*B+f*t*t*C+o*t*D+o*f*E+o*f*t*t*F,r&&(t=2*t/(1-t*t)),a&&(t=1/t),t===1/0&&(t=0x3a052cf8639b6a),e?t:-t}function c(t){return-1==t?Math.PI:n(i(Math.sqrt(1-t*t)/t),Math.PI)}function s(t){return i(t/Math.sqrt(1-t*t))}function h(){Math.sin=f,Math.cos=o,Math.tan=u,Math.acos=c,Math.asin=s,Math.atan=i,Math.hasTrigfills=t()}var M=2*Math.PI,d=Math.PI,l=.5*Math.PI,m=.25*Math.PI,v=.125*Math.PI,p=1/3,I=1.7320508075688772,P=1e8/600000005,x=1/120,y=1e3/5039680,g=10/3628880,q=1e5/2399999,b=1e5/71998376,T=1e3/40578583,j=.3333333342477778,k=1e7/50000082,w=1e5/700011,z=1e4/90019,A=1e3/11768,B=1e9/2999999887,C=2e8/1500000678,D=17e4/3150457,E=6200/282874,F=1382/146286;return{sin:f,cos:o,tan:u,acos:c,asin:s,atan:i,setmaths:h,modp:n,modn:e,version:t}}()},mdname="trigfills",facfnc=trigfillfactory;"undefined"!=typeof exports?"undefined"!=typeof module&&module.exports?exports=module.exports=facfnc({}):exports[mdname]=facfnc({}):"function"==typeof define&&define.amd?define(mdname,[],function(){return facfnc({})}):(0,eval)("this")[mdname]=facfnc({});