CLASS Bezier (Defined in: jpgraph_regstat.php : 112)

Bezier
Bezier() Get()

Class usage and Overview
Utility class to help construct an interpolated data points given an arbitrary number of data points.

This class doesn't draw any graphs by itself it is only used to generate a new set of data points representing the smooth line from the input which are the control lines for a bezier interpolated curve.

The principle of using this class is that you first create an instance of this class and giving it the X,Y values for your control points.

You can then get back an interpolated smooth dataset by calling the Get() method. This method takeas as argument how many data points you want the interpolated graph to have.

In order to use this method the file jpgraph_regstat.php must be included.

Technical note: The control points for a bezier curve does not necessary lie on the curve. Using the alternative method of spline interpolation guarantees that the specified control point lie on the generated curve.

Technical note 2: An alternmative Bezier curve is also availabe in the Canvas tools (jpgraph_canvtools.php). The difference is that that method will not return any data points it will directly draw an interpolate bezier curve on the canvas.

See also related classes:
Spline and Shape

Class Methods

function Bezier($datax,$datay,$attraction_factor,,)
Create a new bezier object

Argument | Default | Description
--- | --- | ---
$datax |  | X-coordinates for control points
$datay |  | Y-coordinates for control points
$attraction_factor |  | Attraction factor
|  | No description available
| 1 | No description available

Description
Creates a new Bezier interpoaltion object. The arguments specifies the X, and Y coordinate sof the control points to be used. The attraction factor is an integer >1 and determines how much "gracity" each control point should have. A higher value makes the resulting curve bend much more sharper against the control points. The default value is 1.

Example

// Control points
$xdata = array(1,3,12,15);
$ydata = array(5,15,2,19);
// Get the interpolated values by creating
// a new bezier object.
$bez = new Bezier($xdata,$ydata);
// For the new data set we want 50 points to
// get a smooth curve.
list($newx,$newy) = $bez->Get(50);

function Get($steps)
Return two arrays of X and Y coordinates that represents the curve

Argument | Default | Description
--- | --- | ---
$steps |  | Number of data points

Description
Return a data set representing the interpolated smooth curve passing through all the specified control points.
Returns
array($datax,$datay)

Example

// Control points for bezier curve
$xdata = array(1,3,12,15);
$ydata = array(5,15,2,19);
// Get the interpolated values by creating
// a new Spline object.
$bez = new Bezier($xdata,$ydata);
// For the new data set we want 50 points to
// get a smooth curve.
list($newx,$newy) = $bez->Get(50);