aUCBLogo Demos and Tests / plottest
to gamma x
local [N nom denom i]
N=12
nom=N^x*faculty N
;(pr x g)
denom=1
for [i 0 N]
[ denom=denom*(x+i)
]
if denom==0 [output 0]
output nom/denom
end
to plot f xmin ymin xmax ymax tickstepx tickstepy
hideTurtle
WindowMode
clearScreen
setPenSize [.5 .5]
PenDown
maxx=330
maxy=250
setX -maxx
setX maxx
setX 0
setY maxy
setY -maxy
setX -maxx
setY maxy
setX maxx
setY -maxy
setX -maxx
tick=10
txtx=25
setH 90
setLabelSize [25 25]
setLabelAlign 0 0
for [y [round ymin] [round ymax] tickstepy]
[ setY maxy*y/ymax
PenDown
setX -maxx+tick
setX -maxx
PenUp
setX maxx-tick
PenDown
setX maxx
PenUp
setX -maxx-txtx
label y
setX -maxx
]
setY -maxy
for [x [round xmin] [round xmax] tickstepx]
[ setX maxx*x/xmax
PenDown
setY -maxy+tick
setY -maxy
PenUp
setY maxy-tick
PenDown
setY maxy
PenUp
setY -maxy-txtx
label x
setY -maxy
]
PenUp
setPenSize [2 2]
y=run list f xmin
setXY -maxx y
for [i 0 2*maxx .1]
[ y2=y
y=(run list f xmin+(xmax-xmin)*i/(2*maxx))/ymax*maxy
if y > maxy [y= maxy]
if y < -maxy [y= -maxy]
ifelse (y != 0) and2 ((signum y)==signum y2) and2 (y != y2)
[ PenDown
][ PenUp
]
setXY i-maxx y
]
updateGraph
end
to plot2 f xmin ymin xmax ymax tx ty
plot f xmin ymin xmax ymax tx ty
(pr "plot word "" f xmin ymin xmax ymax tx ty)
end
to plottest
setUpdateGraph "false
plot2 "radsin -2*pi -1 2*pi 1 1 0.5
plot2 "radcos -2*pi -1 2*pi 1 1 0.5
plot2 "tan -360 -10 360 10 90 5
plot2 "gamma -6 -6 6 6 1 1
end