[racket] plot: HOLY MOLEY!
On 10/31/2011 10:49 PM, John Clements wrote:
> So, I've been plotting the frequency response of chebyshev filters, and I decided to try out the 3d plotting of the new plot:
>
> (define chebyshev-fun (poles&zeros->fun chebyshev-poles '()))
> (plot3d (surface3d (lambda (x y)
> (magnitude (chebyshev-fun
> (+ x (* i y))))))
> #:x-min -1.0
> #:x-max 1.0
> #:y-min -1.0
> #:y-max 1.0
> #:z-max 100.0)
>
> =>
>
>
>
>
>
>
> Which is just absolutely amazing. But then, just on a total whim, I used the mouse to... grab and turn it ?!?? JAW DROPS OPEN HERE.
>
> That was quite a shock. A good one!
>
> Color me sold. I'm just wondering how soon I can show this off to my students.
It'll be in 5.2, which should be released... soon? This month sometime.
If by "show this off to my students" you mean "use it in an HtDP
language", it's usable as soon as students get higher-order functions
(Intermediate). Except for using keyword arguments. Apparently, the HtDP
languages implement them differently. :/
But you don't often need them. For your Chebyshev plot, you could do
this instead:
(plot3d (surface3d (lambda (x y)
(magnitude (chebyshev-fun
(+ x (* i y)))))
-1 1 -1 1))
and it should find a good z-max for you. If it's too large, you can put
the #:z-max argument in the call to 'surface3d'. The 'plot' and 'plot3d'
functions now know how to fit the plot area to plot elements.
FWIW, your reaction to rotating the plot has pasted a two-hour grin onto
my face. :D I was hoping for exactly that when I implemented it.
Neil T