Mojca Miklavec wrote:
On 6/25/06, David Arnold wrote:
Hi,
I confess I got some earlier advice on this issue, but I've never been able to apply it to find a resolution. In the buffer that follows, I define a clipping box:
/.../
Unfortunately, even though this works, mathematicians really want arrows at each end of the graph. Easy enough to do with drawdblarrow P withcolor blue, but the arrows then get clipped. What I really need is to adapt the code below so that my function is clipped to the boundary box, but then redrawn with arrows at each end of it. If anyone can adjust my code to do that, it would be much appreciated, and it would break down a barrier I've faced for years with metapost coding.
Note that I've tried some stuff with cutbefore and cutafter with some success. But I should remark that the code below is generated by a perl script and some special coding we've set up to generate these graphics on the fly for student quizzes. This is not a situation where I can tweak an individual plot or two. Rather, our script might generate 100 sets of the code below, all with different parameters. So this magnifies the problem.
Again, any ideas would be greatly appreciated.
Can you check the attached file? I changed a bit more of the code than you asked for, but I hope that that's not the problem. Only by using "cutbefore/cutafter" you would have to consider too much cases of curve orientation and I avoided the usace of clipping completely. It has some minor problems when drawing a pole of odd orders: this part of the code elseif isInside and (not fallsInside(mytransform((x,ff(x))),cbox)): should be fixed a bit for such cases, so please let me know if you need help for the fix.
The nice part about metapost is that it's a programming language, so you should write your code in such a way that you never code the same number more than once - you should avoid hardcoding the numbers (5 appears quite often in your code) as often as possible.
Please let me know if you need some explanation - I didn't comment much in the source itself. impressive
btw, no need for an if in: vardef fallsInside(expr apoint, cbox) = (xpart apoint >= xpart llcorner cbox) and (xpart apoint <= xpart urcorner cbox) and (ypart apoint >= ypart llcorner cbox) and (ypart apoint <= ypart urcorner cbox) enddef; ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------