Guest User

Untitled

a guest
May 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. class SinusoidalWaveform
  4. {
  5. int[] angleArray= null;
  6. int[] resultArray= null;
  7.  
  8. public SinusoidalWaveform(double minAngle, double maxAngle, int size)
  9. {
  10.  
  11. for (int j=0; j < size;j++)
  12. {
  13. for (double i=minAngle; i <= maxAngle; i++)
  14. {
  15. angleArray[j] = (int)((i*(2.0d*Math.PI))/size);
  16.  
  17. resultArray[j] = (int)(Math.Sin(angleArray[j])) ;
  18. }
  19.  
  20. }
  21. }
  22.  
  23. public override string ToString()
  24. {
  25. string result = "";
  26. for (int i=0; i < angleArray.Length; i++)
  27. {
  28. result += string.Format(
  29. "anglearray[{0}]= {1:F2}, resultarray [{2}]= {3:f2}\n",
  30. i, angleArray[i], i, resultArray[i]);
  31. }
  32. return result;
  33.  
  34.  
  35. }
  36.  
  37. }
  38.  
  39. class TestProgram
  40. {
  41. public static void Main()
  42. {
  43. SinusoidalWaveform w;
  44.  
  45. w = new SinusoidalWaveform ( 0.0d, 2.0d * Math.PI, 20 );
  46.  
  47. Console.WriteLine( w );
  48. }
  49. }
Add Comment
Please, Sign In to add comment