* Here's a strange one for Metapost gurus
@ 2004-01-04 2:41 David Arnold
2004-01-04 16:08 ` Hartmut Henkel
0 siblings, 1 reply; 3+ messages in thread
From: David Arnold @ 2004-01-04 2:41 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 941 bytes --]
All,
I've run across an interesting bug that I haven't seen before. In the
attached Metpost file, if I delete the last figure (beginfig(8)...endfig),
the file compiles. However, with beginfig(8)...endfig, the file gives this
error:
[1] [2] [3] [4] [5]
[6] [7]
>> path
>> pen
! Not implemented: penoffset(path)of(pen).
<to be read again>
;
pen_pickup_->...part.penoffset.left.of.currentpen;
pen_bot:=ypart.penoffset.r...
<to be read again>
;
l.499 pickup pencircle scaled 2pt;
?
As the code in beginfig(8)...endfig is a simple copy and paste of the code
in beginfig(1)...endfig, this is perplexing to say the least.
If in beginfig(8)...endfig, I replace the lines
%draw pendulum length
pickup pencircle scaled 2pt;
draw A--E;
pickup defaultpen;
with:
%draw pendulum length
draw A--E withpen pencircle scaled 2pt;
Now the file will compile.
This is strange indeed! Any ideas?
[-- Attachment #2: pendula.mp --]
[-- Type: text/plain, Size: 10993 bytes --]
verbatimtex
\input mtplain
etex
input mp-tool
def drawgrid(expr xo,yo,nx,ny,sx,sy)=
begingroup
save cpen,result;
pen cpen;
picture result;
cpen:=pencircle scaled 1pt;
result:=nullpicture;
for x=0 upto nx:
for y=0 upto ny:
addto result doublepath (x*sx,y*sy) withpen cpen;
endfor
endfor
defaultfont:="cmr7";
defaultscale:=7pt/fontsize defaultfont;
for x=0 upto nx:
addto result also thelabel.bot(decimal(x),(x*sx,0)) withpen cpen;
endfor
for y=0 upto ny:
addto result also thelabel.lft(decimal(y),(0,y*sy)) withpen cpen;
endfor;
draw result;
endgroup
enddef;
beginfig(1);
%initialize scale
numeric u; 10u=3in;
%initialize pendulum length
L:=10u;
%initialize points
pair A, B, C, D, E;
A:=origin;
C:=(0,-L);
E:=C rotated 45;
B:=(0,ypart E);
D:=(xpart E, -L);
%draw connecting lines
draw A--C--D--E;
draw B--E;
%draw pendulum length
pickup pencircle scaled 2pt;
draw A--E;
pickup defaultpen;
%angle of deflection
drawarrow anglebetween(A--C,A--E,btex $\theta$ etex);
%draw arc of pendulum
anglelength:=L;
draw anglebetween(A--C,A--E,"") dashed evenly;
%draw pendulum bob
path bob;
bob:=fullcircle scaled 20;
bob:=bob shifted E;
fill bob withcolor 0.85white;
draw bob;
label(btex $m$ etex,E);
%label lengths
label.urt(btex $L$ etex, 0.5[A,E]);
label.bot(btex $x$ etex, 0.5[C,D]);
label.rt(btex $y$ etex, 0.5[D,E]);
label.top(btex $x$ etex, 0.5[B,E]);
label.lft(btex $L-y$ etex, 0.5[A,B]);
label.lft(btex $y$ etex, 0.5[B,C]);
%label vertices
dotlabel.top(btex $A$ etex, A);
dotlabel.lft(btex $B$ etex, B);
dotlabel.llft(btex $C$ etex, C);
dotlabel.lrt(btex $D$ etex, D);
endfig;
beginfig(2);
%initialize scale
numeric u; 10u=3in;
%initialize pendulum length
L:=10u;
%initialize points
pair A, B, C, D, E;
A:=origin;
C:=(0,-L);
E:=C rotated 45;
B:=(0,ypart E);
D:=(xpart E, -L);
%draw connecting lines
draw A--C--D--E;
draw B--E;
%draw pendulum length
pickup pencircle scaled 2pt;
draw A--E;
pickup defaultpen;
%angle of deflection
drawarrow anglebetween(A--C,A--E,btex $\theta$ etex);
%draw arc of pendulum
anglelength:=L;
draw anglebetween(A--C,A--E,"") dashed evenly;
%draw pendulum bob
path bob;
bob:=fullcircle scaled 20;
bob:=bob shifted E;
fill bob withcolor 0.85white;
draw bob;
label(btex $M$ etex,E);
%label lengths
label.urt(btex $L$ etex, 0.5[A,E]);
label.bot(btex $x$ etex, 0.5[C,D]);
label.rt(btex $y$ etex, 0.5[D,E]);
label.top(btex $x$ etex, 0.5[B,E]);
label.lft(btex $L-y$ etex, 0.5[A,B]);
label.lft(btex $y$ etex, 0.5[B,C]);
%label vertices
dotlabel.top(btex $A$ etex, A);
dotlabel.lft(btex $B$ etex, B);
dotlabel.llft(btex $C$ etex, C);
dotlabel.lrt(btex $D$ etex, D);
endfig;
beginfig(3);
%initialize scale
numeric u; 1u=0.125in;
%draw thin rod
path rod;
rod:=(0,0)--(20u,0)--(20u,1u)--(0,1u)--cycle;
draw rod;
%draw mass element
path element;
element:=(0,0)--(1u,0)--(1u,1u)--(0,1u)--cycle;
element:=element shifted (14u,0);
fill element withcolor 0.85white;
draw element;
%ticks
path tick;
tick:=(0,0)--(0,-0.25u);
draw tick;
draw tick shifted (20u,0);
draw tick shifted (14.5u,0);
%labels
label.bot(btex $0$ etex, (0,-0.25u));
label.bot(btex $L$ etex, (20u,-0.25u));
label.top(btex $dx$ etex, (14.5u,1u));
label.bot(btex $x$ etex, (14.5u,-0.25u));
endfig;
beginfig(4);
%initialize scale
numeric u; 10u=3in;
%initialize pendulum length
L:=10u;
%initialize points
pair A, B, C, D, E, F, G, H, I;
A:=origin;
C:=(0,-L);
E:=C rotated 45;
B:=(0,ypart E);
D:=(xpart E, -L);
F:=0.5[A,E];
G:=(xpart F,0);
H:=(xpart E,0);
I:=(xpart G, ypart B);
%draw connecting lines
draw A--B;
draw A--H;
draw G--F dashed evenly;
draw H--E dashed evenly;
%draw pendulum length
pickup pencircle scaled 2pt;
draw A--E;
pickup defaultpen;
%angle of deflection
anglelength:=20pt;
drawarrow anglebetween(A--C,A--E,btex $\theta$ etex);
%label lengths
label.urt(btex $L/2$ etex, 0.5[A,F]);
label.urt(btex $L/2$ etex, 0.5[F,E]);
label.top(btex $(L/2)\sin\theta$ etex, 0.5[A,G]);
label.top(btex $(L/2)\sin\theta$ etex, 0.5[G,H]);
%label vertices
dotlabel.top(btex $A$ etex, A);
%draw forces
pickup pencircle scaled 2pt;
drawarrow E--D;
drawarrow F--I;
%label forces
label.bot(btex $mg$ etex, I);
label.bot(btex $Mg$ etex, D);
endfig;
beginfig(5);
%initialize scale
numeric u; 10u=3in;
%initialize pendulum length
L:=10u;
%initialize points
pair A, B, C, D, E, F, G;
A:=origin;
C:=(0,-L);
E:=C rotated 45;
B:=(0,ypart E);
D:=(xpart E, -L);
F:=0.5[A,B];
G:=0.5[A,E];
%draw connecting lines
draw A--C--D--E;
draw B--E;
%draw pendulum length
pickup pencircle scaled 2pt;
draw A--E;
pickup defaultpen;
%angle of deflection
drawarrow anglebetween(A--C,A--E,btex $\theta$ etex);
%draw arc of pendulum
anglelength:=L;
draw anglebetween(A--C,A--E,"") dashed evenly;
%draw pendulum bob
path bob;
bob:=fullcircle scaled 20;
bob:=bob shifted E;
fill bob withcolor 0.85white;
draw bob;
label(btex $M$ etex,E);
%label lengths
label.urt(btex $L/2$ etex, 0.5[A,G]);
label.urt(btex $L/2$ etex, 0.5[G,E]);
label.bot(btex $x$ etex, 0.5[C,D]);
label.rt(btex $y$ etex, 0.5[D,E]);
label.top(btex $x$ etex, 0.5[B,E]);
label.lft(btex $y$ etex, 0.5[B,C]);
%label vertices
dotlabel.top(btex $A$ etex, A);
dotlabel.lft(btex $B$ etex, B);
dotlabel.llft(btex $C$ etex, C);
dotlabel.lrt(btex $D$ etex, D);
%more labels
drawdot(G) withpen pencircle scaled 6pt;
label.urt(btex $m$ etex, G shifted (3,0));
draw F--G;
label.lft(btex $(L/2)\cos\theta$ etex, 0.5[A,F]);
label.lft(btex $(L/2)\cos\theta$ etex, 0.5[F,B]);
endfig;
beginfig(6);
%initialize scale
numeric u; 1u=0.25in;
% drawgrid(0,0,20,10,1u,1u);
%draw line for measurement later
draw (0,0)--(10u,0);
%draw base for pivot
path base;
base:=unitsquare xyscaled (4u,1u);
base:=base shifted (8u,-2u);
stripe_path_a(withcolor black)(draw)
base withcolor white;
draw (8u,-1u)--(12u,-1u);
%draw pivot
path tri;
tri:=(-1,-1)--(0,1)--(1,-1)--cycle;
tri:=tri scaled u;
tri:=tri shifted (10u,0);
fill tri withcolor 0.85white;
%initialize pendulum
path pend;
pend:=(9.5,-0.5)--(10.5,-0.5)--(10.5,10.5)--(9.5,10.5)--cycle;
pend:=pend scaled u;
draw pend;
%draw pivot point
drawdot(10u,0) withpen pencircle scaled 6pt;
%draw spring block left
path left;
left:=(2,9)--(3,9)--(3,11)--(2,11)--cycle;
left:=left scaled u;
stripe_path_a(withcolor black)(draw)
left withcolor white;
draw (3u,9u)--(3u,11u);
%draw spring block right
path right;
right:=(17,9)--(18,9)--(18,11)--(17,11)--cycle;
right:=right scaled u;
stripe_path_a(withcolor black)(draw)
right withcolor white;
draw (17u,9u)--(17u,11u);
%spring
path spring, link;
link:=(0,0)--(0.25,0.5)--(0.75,-0.5)--(1,0);
spring:=link;
for k=1 upto 2:
spring:=spring--(link shifted (k,0));
endfor
spring:=spring scaled u;
%left spring
draw (3u,10u)--(5u,10u);
draw spring shifted (5u,10u);
draw (8u,10u)--(10u,10u);
%right spring
draw (10u,10u)--(12u,10u);
draw spring shifted (12u,10u);
draw (15u,10u)--(17u,10u);
%draw spring contact point
drawdot(10u,10u) withpen pencircle scaled 6pt;
%label springs
label(btex $k$ etex, (6.5u,11u));
label(btex $k$ etex, (13.5u,11u));
%label some measurement lengths
pair A, B, C, D, E;
A:=(1u,0);
B:=(1u,10u);
C:=(5u,0);
D:=(5u,5u);
E:=(10u,5u);
drawdblarrow A--B;
label.lft(btex $L$ etex, 0.5[A,B]);
drawdblarrow C--D;
draw (0,10u)--(2u,10u);
label.lft(btex $L/2$ etex, 0.5[C,D]);
draw (4u,5u)--(6u,5u);
drawdot(E) withpen pencircle scaled 6pt;
label.top(btex cm etex,E shifted (0,5));
endfig;
beginfig(7);
%initialize scale
numeric u; 1u=0.25in;
% drawgrid(0,0,20,10,1u,1u);
%draw line for measurement later
draw (4u,0)--(10u,0);
%draw base for pivot
path base;
base:=unitsquare xyscaled (4u,1u);
base:=base shifted (8u,-2u);
stripe_path_a(withcolor black)(draw)
base withcolor white;
draw (8u,-1u)--(12u,-1u);
%draw pivot
path tri;
tri:=(-1,-1)--(0,1)--(1,-1)--cycle;
tri:=tri scaled u;
tri:=tri shifted (10u,0);
fill tri withcolor 0.85white;
%initialize pendulum
path pend;
pend:=(9.5,-0.5)--(10.5,-0.5)--(10.5,10.5)--(9.5,10.5)--cycle;
pend:=pend scaled u;
draw pend rotatedabout((10u,0),-angle((8,6)));
%draw pivot point
drawdot(10u,0) withpen pencircle scaled 6pt;
%label some measurement lengths
pair A, B, C, D, E, F, G, H, P;
A:=(5u,0);
B:=(5u,8u);
C:=(10u,10u);
D:=(16u,10u);
E:=(10u,5u);
G:=(16u,8u);
H:=(12u,8u);
P:=(10u,0);
draw P--C dashed evenly;
drawdblarrow A--B;
label.lft(btex $L\cos\theta$ etex, 0.5[A,B]);
draw (4u,8u)--G dashed evenly;
drawdblarrow C--D;
label.top(btex $L\sin\theta$ etex, 0.5[C,D]);
E:=E rotatedabout((10u,0),-angle(4,3));
drawdot(E) withpen pencircle scaled 6pt;
label.top(btex cm etex,E shifted (0,5));
drawdot(G) withpen pencircle scaled 6pt;
draw G--D dashed evenly;
%draw force of spring
drawarrow G--H withpen pencircle scaled 2pt;
label.bot(btex $2kL\sin\theta$ etex, H);
%draw force of pendulum mass
F:=(xpart E, 2u);
drawarrow E--F withpen pencircle scaled 2pt;
label.lrt(btex $mg$ etex, F);
%another measurement
pair M, N;
M:=(7u,0);
N:=(7u,4u);
drawdblarrow M--N;
label.rt(btex $(L/2)\cos\theta$ etex, 0.5[M,N]);
draw N--E dashed evenly;
%mark angle
anglelength:=40pt;
drawarrow anglebetween(P--C,P--G,btex $\theta$ etex);
draw P--G dashed evenly;
endfig;
beginfig(8);
%initialize scale
numeric u; 10u=3in;
%initialize pendulum length
L:=10u;
%initialize points
pair A, B, C, D, E;
A:=origin;
C:=(0,-L);
E:=C rotated 45;
B:=(0,ypart E);
D:=(xpart E, -L);
%draw connecting lines
draw A--C--D--E;
draw B--E;
%draw pendulum length
draw A--E withpen pencircle scaled 2pt;
%angle of deflection
drawarrow anglebetween(A--C,A--E,btex $\theta$ etex);
%draw arc of pendulum
anglelength:=L;
draw anglebetween(A--C,A--E,"") dashed evenly;
%draw pendulum bob
path bob;
bob:=fullcircle scaled 20;
bob:=bob shifted E;
fill bob withcolor 0.85white;
draw bob;
label(btex $m$ etex,E);
%label lengths
label.urt(btex $L$ etex, 0.5[A,E]);
label.bot(btex $x$ etex, 0.5[C,D]);
label.rt(btex $y$ etex, 0.5[D,E]);
label.top(btex $x$ etex, 0.5[B,E]);
label.lft(btex $L-y$ etex, 0.5[A,B]);
label.lft(btex $y$ etex, 0.5[B,C]);
%label vertices
dotlabel.top(btex $A$ etex, A);
dotlabel.lft(btex $B$ etex, B);
dotlabel.llft(btex $C$ etex, C);
dotlabel.lrt(btex $D$ etex, D);
endfig;
end.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Here's a strange one for Metapost gurus
2004-01-04 2:41 Here's a strange one for Metapost gurus David Arnold
@ 2004-01-04 16:08 ` Hartmut Henkel
2004-01-04 17:32 ` David Arnold
0 siblings, 1 reply; 3+ messages in thread
From: Hartmut Henkel @ 2004-01-04 16:08 UTC (permalink / raw)
Cc: David Arnold
Hi David,
it happens already in figure 6! By writing
path left;
...
path right;
you have redefined internal things "left" and "right". With e. g.
%draw spring block left
path xleft;
xleft:=(2,9)--(3,9)--(3,11)--(2,11)--cycle;
xleft:=xleft scaled u;
stripe_path_a(withcolor black)(draw)
xleft withcolor white;
draw (3u,9u)--(3u,11u);
%draw spring block right
path xright;
xright:=(17,9)--(18,9)--(18,11)--(17,11)--cycle;
xright:=xright scaled u;
stripe_path_a(withcolor black)(draw)
xright withcolor white;
draw (17u,9u)--(17u,11u);
it works.
Regards, Hartmut
------------------------------------------------------------------------
Hartmut Henkel, Oftersheim, Germany
------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Here's a strange one for Metapost gurus
2004-01-04 16:08 ` Hartmut Henkel
@ 2004-01-04 17:32 ` David Arnold
0 siblings, 0 replies; 3+ messages in thread
From: David Arnold @ 2004-01-04 17:32 UTC (permalink / raw)
Hartmut,
Good eyes! Exactly right, or should I say xright?
Thanks.
At 05:08 PM 1/4/04 +0100, you wrote:
>Hi David,
>
>it happens already in figure 6! By writing
>
>path left;
>...
>path right;
>
>you have redefined internal things "left" and "right". With e. g.
>
> %draw spring block left
> path xleft;
> xleft:=(2,9)--(3,9)--(3,11)--(2,11)--cycle;
> xleft:=xleft scaled u;
> stripe_path_a(withcolor black)(draw)
> xleft withcolor white;
> draw (3u,9u)--(3u,11u);
>
> %draw spring block right
> path xright;
> xright:=(17,9)--(18,9)--(18,11)--(17,11)--cycle;
> xright:=xright scaled u;
> stripe_path_a(withcolor black)(draw)
> xright withcolor white;
> draw (17u,9u)--(17u,11u);
>
>it works.
>
>Regards, Hartmut
>
>
>------------------------------------------------------------------------
>Hartmut Henkel, Oftersheim, Germany
>------------------------------------------------------------------------
>_______________________________________________
>ntg-context mailing list
>ntg-context@ntg.nl
>http://www.ntg.nl/mailman/listinfo/ntg-context
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-04 17:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-04 2:41 Here's a strange one for Metapost gurus David Arnold
2004-01-04 16:08 ` Hartmut Henkel
2004-01-04 17:32 ` David Arnold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).