[metapost] how to draw the water flow
Dan Luecking
luecking at uark.edu
Thu Jun 11 21:39:30 CEST 2009
At 01:25 PM 6/10/2009, you wrote:
>Hi,
>
>I'm new to the Metapost. I want to draw some figures whick looks
>like the water-flow (see the attachment). Dose anyone show me how
>to draw them? Thank you very much.
The other responses drew circles. But we all :-) know the
canonical flow consists of hyperbolas.
The following pathe (f1 and f2) are not hyperbolas, they are
just generic paths, but I have fiddled with them to make them
match hyperbolas, at least with respect to the starting and
ending directions:
% Decide on a size for each quadrant
numeric size; size := 1in;
% Pick the start (p[i]) and end (q[i]) of each flow line
% in the first quadrant:
pair p[], q[];
p1 := (.1,1)*size;
p2 := (.3,1)*size;
q1 := (1,.1)*size;
q2 := (1,.3)*size;
%Define the paths of the flow lines
path f[];
f1 := p1{down+.1right}..q1{right+.1down};
f2 := p2{down+.3right}..q2{right+.3down};
% Define paths for the straight lines
f3 := (0,size)--(0,0);
f4 := (0,0)--(size,0);
f5 := f3 yscaled -1;
f6 := f4 xscaled -1;
% Draw flowlines in one quadrant
picture P;
pickup pencircle scaled 1bp;
P := image(
drawarrow subpath(0,.5) of f1;
drawarrow subpath(0,.5) of f2;
draw subpath(.5,1) of f1;
draw subpath(.5,1) of f2
);
% reflect or rotate to get all four copies:
P := image(
draw P;
draw P xscaled -1;
draw P yscaled -1;
draw P rotated 180;
);
% add the straight lines
P := image(
draw P;
for n = 3 upto 6:
drawarrow subpath (0,.5) of f[n];
draw subpath (.5,1) of f[n];
endfor
);
% rotate 45 degrees to get the desired orientation:
beginfig(1);
draw P rotated -45 shifted (size,size);
endfig;
end
Regards,
Dan
Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas
"Dubito ergo cogito, cogito ergo sum" --Descartes
More information about the metapost
mailing list