/*if (!(isset($_REQUEST["xmin"]) && isset($_REQUEST["xmax"]) && isset($_REQUEST["xscl"]) && isset($_REQUEST["ymin"]) && isset($_REQUEST["ymax"]) && isset($_REQUEST["yscl"]) && isset($_REQUEST["f"]))) die("Parameters must be set: xmin, xmax, xscl, ymin, ymax, yscl, f");*/ $PARAM['xmin'] = -3.14*4;//$_REQUEST['xmin']; $PARAM['xmax'] = 3.14*4;//$_REQUEST['xmax']; $PARAM['xscl'] = (3.14/2);//$_REQUEST['xscl']; $PARAM['ymin'] = -4;//$_REQUEST['ymin']; $PARAM['ymax'] = 4;//$_REQUEST['ymax']; $PARAM['yscl'] = .5;//$_REQUEST['yscl']; $PARAM['f'] = 3;//$_REQUEST['f']; $PARAM['h'] = 25;//$_REQUEST['h']; $PARAM['w'] = 101;//$_REQUEST['w']; if ($PARAM['xmin'] > $PARAM['xmax']) swapvar($PARAM['xmin'], $PARAM['xmax']); if ($PARAM['ymin'] > $PARAM['ymax']) swapvar($PARAM['ymin'], $PARAM['ymax']); $PARAM['xscl'] = abs($PARAM['xscl']); $PARAM['yscl'] = abs($PARAM['yscl']); if ($PARAM['h'] < 25) $PARAM['h'] = 25; if ($PARAM['w'] < 50) $PARAM['w'] = 50; if ($PARAM['xmin'] > 0 || $PARAM['xmax'] < 0) $AXIS['y'] = false; else { $AXIS['y'] = ($PARAM['w'] / (abs($PARAM['xmin']) + $PARAM['xmax'])) * abs($PARAM['xmin']); } if ($PARAM['ymin'] > 0 || $PARAM['ymax'] < 0) $AXIS['x'] = false; else { $AXIS['x'] = ($PARAM['h'] / (abs($PARAM['ymin']) + $PARAM['ymax'])) * abs($PARAM['ymax']); } echo "
"; for ($y = 0; $y < $PARAM['h']; $y++) { for ($x = 0; $x < $PARAM['w']; $x+=(($PARAM['xmax']-$PARAM['xmin'])/$PARAM['w'])) { $xaxis = false; $yaxis = false; $xval = $PARAM['xmax'] - ($x / ($PARAM['w'] / ($PARAM['xmax'] - $PARAM['xmin']))); $f = (($PARAM['h'] / ($PARAM['ymax'] - $PARAM['ymin'])) * (sin($x)/*$PARAM['f']*/) + $PARAM['ymax']); if ($y == floor($f)) echo "*"; else { if ($y == floor($AXIS['x'])) $xaxis = true; if ($x == floor($AXIS['y'])) $yaxis = true; if ($xaxis && $yaxis) echo "+"; else if ($xaxis) echo "-"; else if ($yaxis) echo "|"; else echo " "; } } echo "\n"; $x = 0; } echo ""; function swapvar(&$v1, &$v2) { $temp = $v1; $v1 = $v2; $v2 = $temp; } ?>