Upgrade jpgrah to 4.3.4

This commit is contained in:
Nigel Sheldon 2021-01-03 17:10:26 +01:00
commit b5868f05f6
72 changed files with 19157 additions and 10327 deletions

View file

@ -1,13 +1,13 @@
<?php
/*=======================================================================
// File: JPGRAPH_REGSTAT.PHP
// Description: Regression and statistical analysis helper classes
// Created: 2002-12-01
// Ver: $Id: jpgraph_regstat.php 781 2006-10-08 08:07:47Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
// File: JPGRAPH_REGSTAT.PHP
// Description: Regression and statistical analysis helper classes
// Created: 2002-12-01
// Ver: $Id: jpgraph_regstat.php 1131 2009-03-11 20:08:24Z ljp $
//
// Copyright (c) Asial Corporation. All rights reserved.
//========================================================================
*/
//------------------------------------------------------------------------
// CLASS Spline
@ -20,10 +20,10 @@ class Spline
private $xdata;
private $ydata; // Data vectors
private $y2; // 2:nd derivate of ydata
private $y2; // 2:nd derivate of ydata
private $n=0;
public function Spline($xdata, $ydata)
public function __construct($xdata, $ydata)
{
$this->y2 = array();
$this->xdata = $xdata;
@ -52,7 +52,7 @@ class Spline
$p = $s*$this->y2[$i-1]+2.0;
$this->y2[$i] = ($s-1.0)/$p;
$delta[$i] = ($ydata[$i+1]-$ydata[$i])/($xdata[$i+1]-$xdata[$i]) -
($ydata[$i]-$ydata[$i-1])/($xdata[$i]-$xdata[$i-1]);
($ydata[$i]-$ydata[$i-1])/($xdata[$i]-$xdata[$i-1]);
$delta[$i] = (6.0*$delta[$i]/($xdata[$i+1]-$xdata[$i-1])-$s*$delta[$i-1])/$p;
}
@ -106,7 +106,7 @@ class Spline
$a = ($this->xdata[$max]-$xpoint)/$h;
$b = ($xpoint-$this->xdata[$min])/$h;
return $a*$this->ydata[$min]+$b*$this->ydata[$max]+
(($a*$a*$a-$a)*$this->y2[$min]+($b*$b*$b-$b)*$this->y2[$max])*($h*$h)/6.0;
(($a*$a*$a-$a)*$this->y2[$min]+($b*$b*$b-$b)*$this->y2[$max])*($h*$h)/6.0;
}
}
@ -121,13 +121,13 @@ class Bezier
* @license released under QPL
* @abstract Bezier interoplated point generation,
* computed from control points data sets, based on Paul Bourke algorithm :
* http://astronomy.swin.edu.au/~pbourke/curves/bezier/
* http://local.wasp.uwa.edu.au/~pbourke/geometry/bezier/index2.html
*/
private $datax = array();
private $datay = array();
private $n=0;
public function Bezier($datax, $datay, $attraction_factor = 1)
public function __construct($datax, $datay, $attraction_factor = 1)
{
// Adding control point multiple time will raise their attraction power over the curve
$this->n = count($datax);
@ -150,22 +150,35 @@ class Bezier
$this->n *= $attraction_factor;
}
/**
* Return a set of data points that specifies the bezier curve with $steps points
* @param $steps Number of new points to return
* @return array($datax, $datay)
*/
public function Get($steps)
{
$datax = array();
$datay = array();
for ($i = 0; $i < $steps; $i++) {
list($datumx, $datumy) = $this->GetPoint((double) $i / (double) $steps);
$datax[] = $datumx;
$datay[] = $datumy;
$datax[$i] = $datumx;
$datay[$i] = $datumy;
}
$datax[] = end($this->datax);
$datay[] = end($this->datay);
return array($datax, $datay);
}
/**
* Return one point on the bezier curve. $mu is the position on the curve where $mu is in the
* range 0 $mu < 1 where 0 is tha start point and 1 is the end point. Note that every newly computed
* point depends on all the existing points
*
* @param $mu Position on the bezier curve
* @return array($x, $y)
*/
public function GetPoint($mu)
{
$n = $this->n - 1;