Ejemplo n.º 1
0
  public static void cubicTest() {

    double[] temp = new double[42];

    for (int i = 0; i < LOOPS; i++)
      Curves.calculateCubicCurveOpt2(x0, y0, x1, y1, x2, y2, x3, y3, temp);
  }
Ejemplo n.º 2
0
  private void testOptic() {

    System.out.println("Startframe");

    JFrame frame = new JFrame();

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    MyPanel panel1 = new MyPanel("Cubic-Test");
    MyPanel panel2 = new MyPanel("Quad-Test");

    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panel1, panel2);
    pane.setDividerLocation(0.5);

    frame.add(pane);

    frame.setSize(1000, 600);
    frame.setVisible(true);

    double[] temp1 = new double[42];
    double[] temp2 = new double[42];

    // cubic test
    for (int i = 0; i < 5; i++) {
      x0 = r.nextDouble() * SCALE;
      y0 = r.nextDouble() * SCALE;
      x1 = r.nextDouble() * SCALE;
      y1 = r.nextDouble() * SCALE;
      x2 = r.nextDouble() * SCALE;
      y2 = r.nextDouble() * SCALE;
      x3 = r.nextDouble() * SCALE;
      y3 = r.nextDouble() * SCALE;
      Curves.calculateCubicCurveOpt2(x0, y0, x1, y1, x2, y2, x3, y3, temp1);
      panel1.addPoints1(temp1);
      Curves.calculateCubicCurve(x0, y0, x1, y1, x2, y2, x3, y3, temp2);
      panel1.addPoints2(temp2);
    }

    // quad test
    for (int i = 0; i < 5; i++) {
      x0 = r.nextDouble() * SCALE;
      y0 = r.nextDouble() * SCALE;
      x1 = r.nextDouble() * SCALE;
      y1 = r.nextDouble() * SCALE;
      x2 = r.nextDouble() * SCALE;
      y2 = r.nextDouble() * SCALE;
      Curves.calculateQuadCurveOpt2(x0, y0, x1, y1, x2, y2, temp1);
      panel2.addPoints1(temp1);
      Curves.calculateQuadCurve(x0, y0, x1, y1, x2, y2, temp2);
      panel2.addPoints2(temp2);
    }
  }