示例#1
0
 /**
   * Plots bars from (0, <em>a</em><sub><em>i</em></sub>) to
   * (<em>a</em><sub><em>i</em></sub>) for each <em>i</em>
   * to standard draw.
   *
   * @param a the array of values
   */
  public static void plotBars(double[] a) {
      validateNotNull(a);
      int n = a.length;
      StdDraw.setXscale(-1, n);
      for (int i = 0; i < n; i++) {
          StdDraw.filledRectangle(i, a[i]/2, 0.25, a[i]/2);
      }
  }
示例#2
0
 /**
   * Plots the line segments connecting 
   * (<em>i</em>, <em>a</em><sub><em>i</em></sub>) to
   * (<em>i</em>+1, <em>a</em><sub><em>i</em>+1</sub>) for 
   * each <em>i</em> to standard draw.
   *
   * @param a the array of values
   */
  public static void plotLines(double[] a) {
      validateNotNull(a);
      int n = a.length;
      StdDraw.setXscale(-1, n);
      StdDraw.setPenRadius();
      for (int i = 1; i < n; i++) {
          StdDraw.line(i-1, a[i-1], i, a[i]);
      }
  }
示例#3
0
 /**
   * Plots the points (0, <em>a</em><sub>0</sub>), (1, <em>a</em><sub>1</sub>), ...,
   * (<em>n</em>-1, <em>a</em><sub><em>n</em>-1</sub>) to standard draw.
   *
   * @param a the array of values
   */
  public static void plotPoints(double[] a) {
      validateNotNull(a);
      int n = a.length;
      StdDraw.setXscale(-1, n);
      StdDraw.setPenRadius(1.0 / (3.0 * n));
      for (int i = 0; i < n; i++) {
          StdDraw.point(i, a[i]);
      }
  }
示例#4
0
    /**/ public static void main(string[] strarr)
    {
        StdDraw.setXscale(0.045454545454545456, 0.95454545454545459);
        StdDraw.setYscale(0.045454545454545456, 0.95454545454545459);
        StdDraw.show(0);
        Particle[] array;
        if (strarr.Length == 1)
        {
            int num = Integer.parseInt(strarr[0]);
            array = new Particle[num];
            for (int i = 0; i < num; i++)
            {
                array[i] = new Particle();
            }
        }
        else
        {
            int num = StdIn.readInt();
            array = new Particle[num];
            for (int i = 0; i < num; i++)
            {
                double d  = StdIn.readDouble();
                double d2 = StdIn.readDouble();
                double d3 = StdIn.readDouble();
                double d4 = StdIn.readDouble();
                double d5 = StdIn.readDouble();
                double d6 = StdIn.readDouble();
                int    r  = StdIn.readInt();
                int    g  = StdIn.readInt();
                int    b  = StdIn.readInt();
                Color  c  = new Color(r, g, b);
                array[i] = new Particle(d, d2, d3, d4, d5, d6, c);
            }
        }
        CollisionSystem collisionSystem = new CollisionSystem(array);

        collisionSystem.simulate(10000.0);
    }