@Override
  public String toScript() {
    if (script != null) return script;

    StringBuilder sb = new StringBuilder(1000);

    // Build all hyperplanes x*(p-q) >= 0
    sb.append("my $hyper = new Matrix<Rational>([");

    boolean first = true;
    for (Point point : this.points) {
      // Corrects some problems for bad voronoi cells
      if (!this.orientationCheck(point)) continue;

      if (!first) {
        sb.append(",");
      }
      else {
        first = false;
      }
      sb.append("[0.0");
      for (int i = 0; i < dim; i++) {

        sb.append(", " +
            (this.center.getComponents()[i] - point.getComponents()[i]));
      }
      sb.append("]");
    }
    sb.append("]);");

    // Build the affine hyperplane (x-p)*p = 0
    sb.append("my $aff = new Matrix<Rational>([");
    double val = 0;
    for (double c : this.center.getComponents())
      val -= c * c;
    sb.append("[" + val);
    for (int i = 0; i < this.center.getComponents().length; i++) {
      sb.append(" , " + this.center.getComponents()[i]);
    }
    sb.append("]]);");

    sb.append("my $poly = new Polytope(INEQUALITIES=>$hyper, EQUATIONS=>$aff);");
    sb.append("print $poly->BOUNDED;print \"\\n\";");
    sb.append("print $poly->VERTICES;");
    sb.append("print \"-----\\n\";");
    sb.append("print $poly->GRAPH->EDGES;");
    sb.append("print \"-----\\n\";");
    sb.append("print $poly->FACETS;");

    this.script = sb.toString();
    return this.script;
  }