funcplot.py revision 659d437ab1fa196d010c1e92b009b608b8e8b086
'''
Copyright (C) 2006 Georg Wiora, xorx@quarkbox.de
Copyright (C) 2006 Johan Engelen, johan@shouraizou.nl
Copyright (C) 2005 Aaron Spike, aaron@ekips.org
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Changes:
* This program is a modified version of wavy.py by Aaron Spike.
* 22-Dec-2006: Wiora : Added axis and isotropic scaling
'''
from math import *
from random import *
# coords and scales based on the source rect
# Check for isotropic scaling and use smaller of the two scales, correct ranges
if isoscale:
# compute zero location
# set scale
# correct x-offset
else :
# compute zero location
# set scale
# correct x-offset
# functions specified by the user
if fx != "":
if fpx != "":
# step is the distance between nodes on x
a = [] # path array
# add axis
if drawaxis :
# check for visibility of x-axis
# xaxis
# check for visibility of y-axis
# xaxis
# initialize function and derivative for 0;
# they are carried over from one iteration to the next, to avoid extra function calculations.
else: # derivative given by the user
# Start curve
y1 = f(x)
else: # derivative given by the user
# create curve
return a
help="Start x-value")
help="End x-value")
help="Multiply x-range by 2*pi")
help="y-value of rectangle's bottom")
help="y-value of rectangle's top")
help="Samples")
help="f(x) for plotting")
help="Calculate the first derivative numerically")
help="f'(x) for plotting")
help="If True, source rectangle is removed")
help="If True, isotropic scaling is used")
help="If True, axis are drawn")
help="The selected UI-tab when OK was pressed")
help="dummy")
# create new path with basic dimensions of selected rectangle
#copy attributes of rect
try:
except AttributeError:
pass
# top and bottom where exchanhged
w,h,x,y+h,
#newpath.setAttribute('desc', '!func;' + self.options.fofx + ';'
# + self.options.fpofx + ';'
# + `self.options.fponum` + ';'
# + `self.options.xstart` + ';'
# + `self.options.xend` + ';'
# + `self.options.samples`)
# add path into SVG structure
# option wether to remove the rectangle or not.
e = FuncPlot()
e.affect()