| 1 |
lars |
1 |
<style type="text/css">
|
|
|
2 |
<!--
|
|
|
3 |
A:link {font-family: helvetica, arial, geneva, sans-serif; font-size: x-small; text-decoration: none; color: #0000ff}
|
|
|
4 |
A:visited {font-family: helvetica, arial, geneva, sans-serif; font-size: x-small; text-decoration: none; color: #0000ff}
|
|
|
5 |
A:hover {font-family: helvetica, arial, geneva, sans-serif; font-size: x-small; text-decoration: underline; color: #FF0000}
|
|
|
6 |
th {font-family: helvetica, arial; color : blue; font-size:85%; background : lightgrey; border-right:black solid 1pt; border-bottom:black solid 1pt;}
|
|
|
7 |
//-->
|
|
|
8 |
</style><hr><a name="_C_FUNCGENERATOR"><div style="background-color:yellow;font-family:courier new;"></a>CLASS <b>FuncGenerator</b></div>
|
|
|
9 |
<i>(Defined in: jpgraph.php : 676)</i><table border=1><tr><td> <a href="FuncGenerator.html" style="font-family:arial;font-weight:bold;color:darkblue;">FuncGenerator</a> </td></tr><tr><td valign=top> <a href="FuncGenerator.html#_FUNCGENERATOR_E">E()</a> <br>
|
|
|
10 |
<a href="FuncGenerator.html#_FUNCGENERATOR_FUNCGENERATOR">FuncGenerator()</a> <br>
|
|
|
11 |
</td></tr></table> <p><div style="font-weight:bold;font-family:arial;font-size:100%;">Class usage and Overview</div>A utility class to help with function plots. This class supprots both ordinary one-variable plots with one dependent variable as well as polar plots.
|
|
|
12 |
|
|
|
13 |
Basically you create an instance of this class with the function you want to plot as a string argument. The function should be created using 'x' as the independent variable. You then invoke its evaluation method 'E()' with the range for the independent variable and possibly a step size. The method then returns an array of X, and Y values that represents the plot.
|
|
|
14 |
|
|
|
15 |
Please remember that the string should be specified with single quotes since otherwise PHP will try to interpret the variable in the string.
|
|
|
16 |
|
|
|
17 |
For example, to specify a simple cos() plot you specify:
|
|
|
18 |
|
|
|
19 |
$f = new FuncGenerator('cos($x)';
|
|
|
20 |
<p>
|
|
|
21 |
<hr><span style="font-family:arial;font-size:120%;font-weight:bold;">Class Methods</span><hr><p>
|
|
|
22 |
<p> <p> <span style='font-size:110%;'><a name="_FUNCGENERATOR_E"><div style="border-top:solid black 2pt;background-color:lightblue;font-family:courier new;font-size:90%;font-weight:bold;"><b><font color="#000000">
|
|
|
23 |
function E($aXMin,$aXMax,$aSteps)</font>
|
|
|
24 |
</b></div></a></span>
|
|
|
25 |
|
|
|
26 |
<span style='font-family:arial;font-size:90%;'><i>Evaluate a X-Y function</i></span><p>
|
|
|
27 |
|
|
|
28 |
<table cellspacing=0 style='border:black solid 1pt;' width=100%>
|
|
|
29 |
<tr><th width=25%>Argument</th><th width=15%>Default</th><th width=60%>Description</th></tr>
|
|
|
30 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
31 |
$aXMin</font>
|
|
|
32 |
|
|
|
33 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'> </td><td>Min x-value</td></tr>
|
|
|
34 |
|
|
|
35 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
36 |
$aXMax</font>
|
|
|
37 |
|
|
|
38 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'> </td><td>Max x-value</td></tr>
|
|
|
39 |
|
|
|
40 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
41 |
$aSteps</font>
|
|
|
42 |
|
|
|
43 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
44 |
50</font>
|
|
|
45 |
</td><td>Number of steps</td></tr>
|
|
|
46 |
</table>
|
|
|
47 |
|
|
|
48 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">Description</div>Evaluate the previous specified function between the specified values. The return two arrays representing the X and Y coordinates for the function. <br>
|
|
|
49 |
|
|
|
50 |
<div style="font-weight:bold;font-family:arial;font-size:85%;"><p>Example</div><span style="font-family:courier;font-size:85%;"><font color="#000000">
|
|
|
51 |
// Create a simple linear plot
<br />$f = new FuncGenerator('cos($x) * sin($x)');
<br />list($xdata,$ydata) = $f->E(-2*M_PI, 2*M_PI);
<br />
<br />$lp1 = new LinePlot($ydata,$xdata);
<br />
<br />// Create a simple polar plot (a circle)
<br />$p = new FuncGenerator('cos($i)', 'sin($i)');
<br />list($x2data,$y2data) = $f->E(-2*M_PI, 2*M_PI);
<br />
<br />$lp2 = new LinePlot($y2data,$x2data);
<br />
<br />//...</font>
|
|
|
52 |
</span><br>
|
|
|
53 |
<p>
|
|
|
54 |
<p> <p> <span style='font-size:110%;'><a name="_FUNCGENERATOR_FUNCGENERATOR"><div style="border-top:solid black 2pt;background-color:lightblue;font-family:courier new;font-size:90%;font-weight:bold;"><b><font color="#000000">
|
|
|
55 |
function FuncGenerator($aFunc,$aXFunc)</font>
|
|
|
56 |
</b></div></a></span>
|
|
|
57 |
|
|
|
58 |
<span style='font-family:arial;font-size:90%;'><i>Create a new function generator.</i></span><p>
|
|
|
59 |
|
|
|
60 |
<table cellspacing=0 style='border:black solid 1pt;' width=100%>
|
|
|
61 |
<tr><th width=25%>Argument</th><th width=15%>Default</th><th width=60%>Description</th></tr>
|
|
|
62 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
63 |
$aFunc</font>
|
|
|
64 |
|
|
|
65 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'> </td><td>Function</td></tr>
|
|
|
66 |
|
|
|
67 |
<tr><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
68 |
$aXFunc</font>
|
|
|
69 |
|
|
|
70 |
</td><td style='border-right:black solid 1pt;font-family:courier;font-size:90%;font-weight:bold;'><font color="#000000">
|
|
|
71 |
|
|
|
72 |
</td><td>X-Function</td></tr>
|
|
|
73 |
</table>
|
|
|
74 |
|
|
|
75 |
<div style="font-weight:bold;font-family:arial;font-size:85%;">Description</div>Creates a new funciton generator. You can create both a linear plot as well as polar plot.
|
|
|
76 |
|
|
|
77 |
For linear, one-variable plots, you must use '$x' as the independent variable.
|
|
|
78 |
|
|
|
79 |
For polar plots you should use the index '$i' for the generating functions.
|
|
|
80 |
<br>
|
|
|
81 |
|
|
|
82 |
<div style="font-weight:bold;font-family:arial;font-size:85%;"><p>Example</div><span style="font-family:courier;font-size:85%;"><font color="#000000">
|
|
|
83 |
// Create a simple linear plot
<br />$f = new FuncGenerator('cos($x) * sin($x)');
<br />list($xdata,$ydata) = $f->E(-2*M_PI, 2*M_PI);
<br />
<br />$lp1 = new LinePlot($ydata,$xdata);
<br />
<br />// Create a simple polar plot (a circle)
<br />$p = new FuncGenerator('cos($i)', 'sin($i)');
<br />list($x2data,$y2data) = $f->E(-2*M_PI, 2*M_PI);
<br />
<br />$lp2 = new LinePlot($y2data,$x2data);
<br />
<br />//...
<br /></font>
|
|
|
84 |
</span><br>
|
|
|
85 |
<p> <hr> <p>
|