sincos.lua 286 B

12345678910111213141516171819
  1. local PI = 3.141592653589793
  2. local HALF_PI = PI * 0.5
  3. local mathsin = math.sin
  4. local mathcos = math.cos
  5. local function cos(x)
  6. if x % PI == HALF_PI then
  7. return 0
  8. end
  9. return mathcos(x)
  10. end
  11. local function sin(x)
  12. if x % PI == 0 then
  13. return 0
  14. end
  15. return mathsin(x)
  16. end