Beispiel #1
0
 }
 $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) {
             array_push($x_arr, $x_first);
         }
         array_push($x_arr, $x);
         $empty = false;
     }