Beispiel #1
0
 //exit('{status:"error",value:'.json_encode($xvalues).',xmin:'.$xmin.',xmax:'.$xmax.',dx:'.$dx.',n:'.$n.'}');
 $expr_str = decode($_REQUEST["expression"]);
 if ($expr_str == 'spline') {
     if (!isset($_REQUEST["points"])) {
         exit('{status:"error",value:"Points not given for spline"}');
     }
     $points = json_decode($_REQUEST["points"]);
     $do_fit = false;
     if (isset($_REQUEST["fit"])) {
         $do_fit = $_REQUEST["fit"];
     }
     if (sizeof($points) == 0) {
         exit('{status:"error",value:"Empty points array given for spline"}');
     }
     $spline = new Spline();
     $spline->add_points($points);
     //exit('{status:"error",value:'.json_encode($points).'}');
     if ($do_fit) {
         $spline->fit_derivs();
     } else {
         $spline->fit();
     }
     $x_first = $spline->points[0]->x;
     $x_last = $spline->points[sizeof($spline->points) - 1]->x;
     $x_arr = array();
     $m = sizeof($xvalues);
     $empty = true;
     for ($i = 0; $i < $m; $i += 1) {
         $x = $xvalues[$i];
         if ($x >= $x_first && $x <= $x_last) {
             if ($empty && $x > $x_first) {