Advertisement
calcpage

LACS01-PolarTester.java

May 29th, 2012
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.71 KB | None | 0 0
  1. /**
  2. PolarTester.java    MrG 2012.0529
  3. purpose:    test graphics.jar by making polar graphs!
  4. required files: PolarTester.java            main class
  5.         graphics.jar                utility classes
  6. translator: javac -classpath .:./graphics.jar PolarTester.java
  7. interperter:    java -classpath .:./graphics.jar PolarTester
  8. */
  9. public class PolarTester
  10. {
  11.     public static void main(String[] args)
  12.     {
  13.         StdDraw.setXscale(-1,+1);
  14.         StdDraw.setYscale(-1,+1);
  15.  
  16.         double x0 = 0;
  17.         double y0 = 0;
  18.  
  19.         for(double t=0.0; t<=360.0; t+=0.1)
  20.         {
  21.             double theta = Math.toRadians(t);
  22.             double r = Math.sin(3*theta);
  23.             double x1 = r*Math.cos(theta);
  24.             double y1 = r*Math.sin(theta);
  25.             StdDraw.line(x0,y0,x1,y1);
  26.             x0=x1;
  27.             y0=y1;         
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement