Advertisement
IcarusLives

MathMacros

Mar 19th, 2017
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.41 KB | None | 0 0
  1. :mathMacros
  2.     if not exist FPU-Module.js echo WScript.Stdout.WriteLine(eval(WScript.Stdin.ReadLine().replace(/\x22/g,"")));> FPU-Module.js
  3.     attrib +h +s FPU-Module.js
  4.  
  5.     set /a "PI=(35500000/113+5)/10, PI_div_2=(35500000/113/2+5)/10, PIx2=2*PI, PI32=PI+PI_div_2"
  6.     set "_SIN=a-a*a/1920*a/312500+a*a/1920*a/15625*a/15625*a/2560000-a*a/1875*a/15360*a/15625*a/15625*a/16000*a/44800000"
  7.     set "SIN(x)=(a=(x * 31416 / 180)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"
  8.     set "COS(x)=(a=(15708 - x * 31416 / 180)%%62832, c=(a>>31|1)*a, a-=(((c-47125)>>31)+1)*((a>>31|1)*62832)  +  (-((c-47125)>>31))*( (((c-15709)>>31)+1)*(-(a>>31|1)*31416+2*a)  ), %_SIN%) / 10000"
  9.     set "_SIN="
  10.     set "Sqrt(N)=( x=(N)/(11*1024)+40, x=((N)/x+x)/2, x=((N)/x+x)/2, x=((N)/x+x)/2, x=((N)/x+x)/2, x=((N)/x+x)/2 )"
  11.     set "Sign(n)=(n>>31)|((-n>>31)&1)"
  12.     set "Abs(x)=(((x)>>31|1)*(x))"
  13.    
  14.     set "swap(x,y)=t=x, x=y, y=t"
  15.     set "translate=x+=width / 2, y+=height / 2"
  16.     set "checkBounds=if ^!x^! leq %width% if ^!y^! leq %height% if ^!x^! geq 0 if ^!y^! geq 0"
  17.     goto :eof
  18.    
  19.     :: Javascript maths
  20.     :math rtnvar expr
  21.         echo "%~2" >%TMP%\in.txt
  22.         Cscript //nologo FPU-Module.js <%TMP%\in.txt >%TMP%\out.txt
  23.         set /p "%1=" <%TMP%\out.txt
  24.         set "%1=!%1:,=.!"
  25.     goto :eof
  26. goto :eof
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement