I'm looking for a new idea for something I need to do. I typically
create a path on a domain [-5,5] as follows, a arbitrary. Then I
randomly reflect the path about and axis, a line, or maybe rotate it.
The result is that parts of the path may lie outside a bounding window.
% define linear function f
vardef f(expr x)=
% define paths for functions f, g, and h, respectively
for x=-5 step .1 until 5:
% initialize scale
numeric u; 10u=w;
% scale and draw graph
P:=P scaled u;
draw P withcolor blue;
% clipping path
cpath:=cpath scaled 1u;
% clip and save current picture
clip currentpicture to cpath;
% erase currentpicture
Then I do some stuff I need to do and bring back the path at a later
This works fine. However, what I need to do is somehow clip the path P
to the bounding box, but retain the resulting cutpath in a path
variable Q. That is, I need to cut off the parts of the path P that lie
outside the bounding box cpath:=(-5,-5)--(5,-5)--(5,5)--(-5,5)--cycle
and store the clipped path in the path variable Q. The difficulty is I
have no advance knowledge if the path P lies entirely inside the
bounding box or if it escapes through one of the sides.
Any hints, tips, etc., would be very appreciated.
ntg-context mailing list