Advertisement
calcpage

LACS2013_ParametricMode.java

Jun 1st, 2013
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.94 KB | None | 0 0
  1. //ParametricMode.java   MrG 2013.0521
  2. public class ParametricMode
  3. {
  4.     private double xMin;
  5.     private double xMax;
  6.     private double xScl;
  7.     private double yMin;
  8.     private double yMax;
  9.     private double yScl;
  10.  
  11.     public ParametricMode(double xMin, double xMax, double xScl, double yMin, double yMax, double yScl)
  12.     {
  13.         this.xMin=xMin;
  14.         this.xMax=xMax;
  15.         this.xScl=xScl;
  16.         this.yMin=yMin;
  17.         this.yMax=yMax;
  18.         this.yScl=yScl;
  19.     }
  20.  
  21.     public void axes()
  22.     {
  23.         StdDraw.setPenRadius(.005);
  24.         StdDraw.line(0,yMin,0,yMax);
  25.         StdDraw.line(xMin,0,xMax,0);
  26.         StdDraw.text(xMax,-1,"x");
  27.         StdDraw.text(1,yMax,"y");
  28.     }
  29.  
  30.     public void grid()
  31.     {
  32.         StdDraw.setPenRadius(.001);
  33.         StdDraw.setPenColor(StdDraw.BLUE);
  34.         for(double x=xMin; x<=xMax; x+=xScl)
  35.         {
  36.             StdDraw.line(x,yMin,x,yMax);
  37.         }
  38.         for(double y=yMin; y<=yMax; y+=yScl)
  39.         {
  40.             StdDraw.line(xMin,y,xMax,y);
  41.         }
  42.     }
  43.  
  44.     public void plot()
  45.     {
  46.         StdDraw.setPenRadius(.001);
  47.         StdDraw.setPenColor(StdDraw.GREEN);
  48.         //0 100 10 0 300 10 wiley cyote
  49.         //double t=0;
  50.         //double x0 = 4*t;
  51.         //double y0 = -16*t*t + 96*t + 112;
  52.         //0 300 10 0 100 10 inverse wiley
  53.         //double t=0;
  54.         //double y0 = 4*t;
  55.         //double x0 = -16*t*t + 96*t + 112;
  56.         //-2 2 1 -2 2 1 apophos/miller
  57.         //double t=0;
  58.         //double x0 = -0.7;
  59.         //double y0 = 1.0;
  60.         //-4 4 1 -4 4 1 butterfly/lorentz
  61.         double t=0;
  62.         double x0=0;
  63.         double y0=0;
  64.         for(t=0; true; t+=0.05)
  65.         {
  66.             //0 100 10 0 300 10 wiley cyote
  67.             //double x = 4*t;
  68.             //double y = -16*t*t + 96*t + 112;
  69.             //0 300 10 0 100 10 inverse wiley
  70.             //double y = 4*t;
  71.             //double x = -16*t*t + 96*t + 112;
  72.             //-2 2 1 -2 2 1 apophos
  73.             //double x = Math.sin(0.99*t)-0.7*Math.cos(3.01*t);
  74.             //double y = Math.cos(1.01*t)+0.1*Math.sin(15.03*t);
  75.             //-4 4 1 -4 4 1 butterfly/lorentz
  76.             double r=Math.exp(Math.cos(t))-2*Math.cos(4*t)+Math.pow(Math.sin(t/12),5);
  77.             double x=r*Math.cos(t);
  78.             double y=r*Math.sin(t);
  79.             StdDraw.line(x0,y0,x,y);
  80.             x0=x;
  81.             y0=y;
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement