
是否可以將一對定義為沿著指定路徑長度的點?
例如
beginfig
u=2cm;
path x;
x=(0,0)..u*dir(225);
%v= a point along a fraction of the length of x in a specific direction
endfig
答案1
這沿著以 MetaPost 的 Metafun 格式定義的運算子將點指定為路徑的一部分:
beginfig(1);
u=2cm;
path x; x=(0,0)..u*dir(225); draw x;
pair v; v = point .3 along x;
dotlabel.lrt(btex v etex, v);
endfig;
end.
若要使用mem
標誌進行編譯:mpost --mem=metafun yourfile.mp
.結果:
作為替代方案,您可以mp-tool.mpii
在程式開始時載入該套件(但您將無法享受 Metafun 的全部功能,例如透明度):
input mp-tool.mpii;
或者,如果您想堅持plain
格式,您可以along
自己定義運算符。它是這樣定義的元趣手冊,p。 61:
primarydef pct along pat =
(arctime (pct * (arclength pat)) of pat) of pat
enddef;
在 Metafun 格式中(參見手冊,同上第 61 頁)也是在定義的運算符,它指定具有尺寸的點的位置:
primarydef len on pat =
(arctime len of pat) of pat
enddef;
應用到我們的程式中,它會像這樣使用,以獲得相同的結果:
beginfig(1);
u=2cm;
path x; x=(0,0)..u*dir(225); draw x;
pair v; v = point .6cm on x;
dotlabel.lrt(btex v etex, v);
endfig;
end.