Wednesday, February 18, 2015

Oscilloscope java in pgm



Oscilloscope.java

public class Oscilloscope
{

   public static void main(String[] args)
   {
      StdDraw.setXscale(-1, +1);
      StdDraw.setYscale(-1, +1);

      double A    = Double.parseDouble(args[0]);   
      double B    = Double.parseDouble(args[1]);
      double wX   = Double.parseDouble(args[2]);   
      double wY   = Double.parseDouble(args[3]);
      double phiX = Double.parseDouble(args[4]);   
      double phiY = Double.parseDouble(args[5]);

      phiY = Math.toRadians(phiX);
      phiY = Math.toRadians(phiY);


      for (double t = 0.0; t < 10; t += 0.0001)
      {
         double x = A * Math.sin(wX * t + phiX);
         double y = B * Math.sin(wY * t + phiY);
         StdDraw.point(x, y);
         StdDraw.show(10);
      }
   }
}
 

No comments:

Post a Comment