Advertisement
calcpage

LACS07a_Madness.java

Jun 12th, 2012
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.89 KB | None | 0 0
  1. /*************************************************************************
  2.  *  Compilation:  javac Madness.java
  3.  *  Execution:    java Madness
  4.  *  
  5.  *  Plots a parametric figure which A. K. Dewdney refers to as
  6.  *  Miller's Madness.
  7.  *
  8.  *  Reference: The Magic Machine by A. K. Dewdney. This figure
  9.  *  was designed by Stanley S. Miller, a management consultant.
  10.  *
  11.  *
  12.  *************************************************************************/
  13.  
  14.  
  15. public class Madness {
  16.  
  17.    public static void main(String[] args) {
  18.       StdDraw.setXscale(-1.7, +1.7);
  19.       StdDraw.setYscale(-1.1, +1.1);
  20.       double x0 = -0.7, y0 = 1.0;
  21.       for (double t = 0.0; true; t += 0.01) {
  22.           double x1 = Math.sin(0.99*t) - 0.7*Math.cos(3.01*t);
  23.           double y1 = Math.cos(1.01*t) + 0.1*Math.sin(15.03*t);
  24.           StdDraw.line(x0, y0, x1, y1);
  25.           x0 = x1;
  26.           y0 = y1;
  27.       }
  28.    }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement