Level1.cs 954 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //#define IsTestDownLevel1
  2. #define IsDriverUpperCos
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace FunctionSystem
  9. {
  10. public static class Level1
  11. {
  12. #if IsTestDownLevel1
  13. #region заглушки
  14. public static double Cos(double x) => 1;
  15. #endregion
  16. #elif IsDriverUpperCos
  17. #region
  18. public static double Cos(double x)
  19. {
  20. Console.WriteLine($"Sin - {Level0.Sin(x)}");
  21. return 0;
  22. }
  23. #endregion
  24. #else
  25. public static double Cos(double x)
  26. {
  27. x = ((x / (2 * Math.PI)) - Math.Truncate((x / (2 * Math.PI)))) * Math.PI * 2;
  28. if (x > Math.PI / 2 && x < Math.PI * 3 / 2)
  29. {
  30. return -(Math.Sqrt(1 - Math.Pow(Level0.Sin(x), 2)));
  31. }
  32. return Math.Sqrt(1 - Math.Pow(Level0.Sin(x), 2));
  33. }
  34. #endif
  35. }
  36. }