[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 4 5 /** 6 * Image_Graph - PEAR PHP OO Graph Rendering Utility. 7 * 8 * PHP versions 4 and 5 9 * 10 * LICENSE: This library is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as published by 12 * the Free Software Foundation; either version 2.1 of the License, or (at your 13 * option) any later version. This library is distributed in the hope that it 14 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 16 * General Public License for more details. You should have received a copy of 17 * the GNU Lesser General Public License along with this library; if not, write 18 * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 * 02111-1307 USA 20 * 21 * @category Images 22 * @package Image_Graph 23 * @subpackage Dataset 24 * @author Jesper Veggerby <pear.nosey@veggerby.dk> 25 * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen 26 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 27 * @version CVS: $Id: VectorFunction.php,v 1.6 2005/08/24 20:35:57 nosey Exp $ 28 * @link http://pear.php.net/package/Image_Graph 29 */ 30 31 /** 32 * Include file Image/Graph/Dataset.php 33 */ 34 require_once 'Image/Graph/Dataset.php'; 35 36 /** 37 * Vector Function data set. 38 * 39 * Points are generated by calling 2 external functions, fx. x = sin(t) and y = 40 * cos(t) 41 * 42 * @category Images 43 * @package Image_Graph 44 * @subpackage Dataset 45 * @author Jesper Veggerby <pear.nosey@veggerby.dk> 46 * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen 47 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 48 * @version Release: 0.7.2 49 * @link http://pear.php.net/package/Image_Graph 50 */ 51 class Image_Graph_Dataset_VectorFunction extends Image_Graph_Dataset 52 { 53 54 /** 55 * The name of the X function 56 * @var string 57 * @access private 58 */ 59 var $_functionX; 60 61 /** 62 * The name of the Y function 63 * @var string 64 * @access private 65 */ 66 var $_functionY; 67 68 /** 69 * The minimum of the vector function variable 70 * @var double 71 * @access private 72 */ 73 var $_minimumT; 74 75 /** 76 * The maximum of the vector function variable 77 * @var double 78 * @access private 79 */ 80 var $_maximumT; 81 82 /** 83 * Image_Graph_VectorFunctionDataset [Constructor] 84 * 85 * @param double $minimumT The minimum value of the vector function variable 86 * @param double $maximumT The maximum value of the vector function variable 87 * @param string $functionX The name of the X function, if must be a single 88 * parameter function like fx sin(x) or cos(x) 89 * @param string $functionY The name of the Y function, if must be a single 90 * parameter function like fx sin(x) or cos(x) 91 * @param int $points The number of points to create 92 */ 93 function Image_Graph_Dataset_VectorFunction($minimumT, $maximumT, $functionX, $functionY, $points) 94 { 95 parent::Image_Graph_Dataset(); 96 $this->_minimumT = $minimumT; 97 $this->_maximumT = $maximumT; 98 $this->_functionX = $functionX; 99 $this->_functionY = $functionY; 100 $this->_count = $points; 101 $this->_calculateMaxima(); 102 } 103 104 /** 105 * Add a point to the dataset 106 * 107 * @param int $x The X value to add 108 * @param int $y The Y value to add, can be omited 109 * @param var $ID The ID of the point 110 */ 111 function addPoint($x, $y = false, $ID = false) 112 { 113 } 114 115 /** 116 * Gets a X point from the dataset 117 * 118 * @param var $x The variable to apply the X function to 119 * @return var The X function applied to the X value 120 * @access private 121 */ 122 function _getPointX($x) 123 { 124 $functionX = $this->_functionX; 125 return $functionX ($x); 126 } 127 128 /** 129 * Gets a Y point from the dataset 130 * 131 * @param var $x The variable to apply the Y function to 132 * @return var The Y function applied to the X value 133 * @access private 134 */ 135 function _getPointY($x) 136 { 137 $functionY = $this->_functionY; 138 return $functionY ($x); 139 } 140 141 /** 142 * Reset the intertal dataset pointer 143 * 144 * @return var The first T value 145 * @access private 146 */ 147 function _reset() 148 { 149 $this->_posX = $this->_minimumT; 150 return $this->_posX; 151 } 152 153 /** 154 * The interval between 2 adjacent T values 155 * 156 * @return var The interval 157 * @access private 158 */ 159 function _stepX() 160 { 161 return ($this->_maximumT - $this->_minimumT) / $this->count(); 162 } 163 164 /** 165 * Calculates the X and Y extrema of the functions 166 * 167 * @access private 168 */ 169 function _calculateMaxima() 170 { 171 $t = $this->_minimumT; 172 while ($t <= $this->_maximumT) { 173 $x = $this->_getPointX($t); 174 $y = $this->_getPointY($t); 175 $this->_minimumX = min($x, $this->_minimumX); 176 $this->_maximumX = max($x, $this->_maximumX); 177 $this->_minimumY = min($y, $this->_minimumY); 178 $this->_maximumY = max($y, $this->_maximumY); 179 $t += $this->_stepX(); 180 } 181 } 182 183 } 184 185 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |