HOME > é»ç® > asymptote ã¡ã¢
asymptote ã¡ã¢
AsymptoteïŒhttp://asymptote.sourceforge.net/ïŒã¯ãã¯ã¿ã»ã°ã©ãã£ãã¯ã¹ã®ããã®èšèªãã ãåã§åœä»€ãæžããŠããã¹ãã¹ã¯ãªããã§åºåã§ããããã Metapost ã£ã¡ããã®ãUNIX, Linux, MacOS, Microsoft Windows ãªã©ã§åããLaTeX ã«äŸåããïŒã©ãã«ã LaTeX 圢åŒã§æžãããšã¯ã§ãããïŒãèéãå©ããŠã³ãŒããïŒèªåã®æžãããã€ãªãïŒã¹ãããªèŠããããã䜿ããã«ã³ã¿ã³ãªææ³ãæã€äžæ¹ãä»£å ¥æã«èµ·ããæé»ã®åãã£ã¹ãã®ãµããããŠããã¥ãŒããã¯ã¹ãã©ã€ã³è£éãããŠããŸããªã©ããŠãŒã¶ãæ°ã¥ãã¬ãã¡ã«å€§èïŒãªããšãè¡ãããšããåŸåããããæ¥æ¬èªã¯éããªãïŒåŸæ¥ http://oku.edu.mie-u.ac.jp/~okumura/blog/node/2337 ã«æ¥æ¬èªãéããšæžããŠããã®ãçºèŠããŸã è©ŠããŠããªãïŒã
ãªã³ã¯ïŒœäœãã§ããã®ãæã£åãæ©ãã€ã¡ãŒãžããã人ã¯ãæ¬å®¶ http://asymptote.sourceforge.net/ ã® Document ããå ¬åŒã® Tutorial ããã©ããïŒããããã¥ã¢ã«ãããã«ããïŒãhttp://www.artofproblemsolving.com/Wiki/index.php/Asymptote_%28Vector_Graphics_Language%29 ã«ããã¥ãŒããªã¢ã«ãããããŸããhttp://piprim.tuxfamily.org/asymptote/generale/index.html ã«äœ¿çšäŸãããã
ãŠãœæžããŠãããããããšã£ãŠããŠãœæžããŠãããªæ°ãããâŠâŠ
ã€ã³ã¹ããŒã«ãªã©
æ¬å®¶ã¯ http://asymptote.sourceforge.net/ ã§ãããããããŠã³ããŒããrpm ãšãããããããã® Linux ã¯å€ãããã®ã§ glibc ãå€ããŠãææ°ã® asymptote ã¯ã€ã³ã¹ããŒã«ã§ããªãã ãããããªããããããŒãžã§ã³ 1.18 ãã€ã³ã¹ããŒã«ã
æšæºçãªãã£ã¬ã¯ããªæ§æ
/usr/loca/bin/ æ¬äœ /usr/local/share/asymptote/ ã¢ãžã¥ãŒã« /usr/local/share/doc/ ããã¥ã¡ã³ã /usr/local/info/ infoçš /usr/local/man/man1/ mançš /usr/share/texmf/tex/latex/asymptote/ LaTeX çšã¹ã¿ã€ã«ãã¡ã€ã« ~/.asy/config.asy èšå®ãã¡ã€ã«
èµ·åã¯
$ asy
ã§ã察話ã¢ãŒããã«ã¬ã³ãã»ãã£ã¬ã¯ããªã« out.eps ãšãããã¡ã€ã«ãåºåãããããã(æšæºã§ã¯) gv ã§è¡šç€ºããã
$ asy unko.asy
ã®ããšããããšããã¡ã€ã«ããåœä»€ãèªã¿åãããã®å Žåãã«ã¬ã³ãã»ãã£ã¬ã¯ããªã« unko.esp ãã§ããã ãã-V ãªãã·ã§ã³ãã€ãããšããã¡ã€ã«ã«æžã蟌ãã®ãšåæã« gv ã§è¡šç€ºããŠãããã察話ã¢ãŒããã asymptote ãçµäºãããã«ã¯ã
> quit
ã§ããããã
ãã¯ãã«è¡šçŸãšæŒç®
pair ãšããããŒã¿å
ããŒã¿å ã«ã¯ãvoid, bool, int, real, string ãªã©ããããããã pair ãšãããã€ããã䜿ããããèŠãŠã®ãšãããå®æ°ã®ãã¢ãå¹³é¢åº§æšãããããã®ã«äœ¿ããããã»ãã«ãtriple ããããïŒæ¬¡å çšã
> pair a; // 宣èšïŒïŒæé»ã®åæåïŒ > a=(1,2); // ä»£å ¥
ã§ãa ãå®çŸ©ã§ããã宣èšããããšåæã« (0,0) ã«åæåããããa ã«äœãå ¥ã£ãŠããã®ãèŠãããªãã°ã
> write(a); (1,2)
ã®ãããªå ·åãå€æ°ãè©äŸ¡ããŠãèªç¶ã«åºåãããããã§ã¯ãªããã write( ) ã䜿ãã
pair åãããäžã€ã²ãšã€ã®å®æ°ãåãåºãã«ã¯ ã. ããšãããªãã¬ãŒã¿ã䜿ãã
> pair b = (1,2); // 宣èšïŒä»£å ¥ > write(b.x); 1 > write(b.y); 2
+ - ã®åãªãã¬ãŒã¿ã pair ã«å¯ŸããŠäœ¿ããšã
> pair c = (3,4); > pair d = (5,6); > write(c+d); // 8=3+5 10=4+6 (8,10) > write(c-d); // 3-5=-2 4-6=-2 (-2,-2)
ããã¯ãããããããã次㫠* / ã®ãªãã¬ãŒã¿ã pair ã«å¯ŸããŠäœ¿ã£ãŠã¿ãã
> write(c*2); // ããã¯äºæ³éã > (6,4) > write(c/2); // ãããäºæ³éã > (1.5,2) > write(c*d); // ããã¯ã©ããªãïŒ > (-9,38) > write(c/d); // ããã¯ã©ããªãïŒ > (0.639344262295082,0.0327868852459016)
pair ãšããã®ã¯ããã€ã¯è€çŽ æ°ããããããŠããã®ã ãšããããšãããããããã ã£ãã®ãããã§ããç¥ããé¡ãã㊠pair ã¯ãã ã®ãã¯ãã«ã ãšæã蟌ãã§äœ¿ãããšã«ããã
å®æ°
çµèŸŒã¿å®æ°ã« pi ãšãããã®ãããã
> write(pi) 3.14159265358979
transform ãšãããã®
(a,b,c,d,e,f) 㯠transform ãšãããã®ã§ãããã (x, y) ãšãã pair åã«ã«å·ŠããæããŠãããšãã¢ãã£ã³å€æãã§ãããã€ãŸãã
|a| |c d| |x| | | + | | * | | |b| |e f| |y|
ã«ãªããšããããšãç¹ (2,3) ã x 軞 y 軞æ¹åã« 10 ã ã移åãããã«ã¯
> write ((10,10,1,0,0,1) * (2,3)); (12,13)
ã®ããã«ããã°ããã6 ã€ãæ°åãæžãã®ã¯é¢åã ãããshift(10,10) * (2,3) ãšæžããŠãããããããšã«ãªã£ãŠãããããã¯ãå ã«èŠããšãã (10,10)+(2,3) ã§ãããŸããªããããåæ§ã«ãx, y ãšã 2 åã«ããããã® (0,0,2,0,0,2) 㯠scale(2) ãšæžããŠãããããããããå ã«èŠããšããã2 * (2,3) ã§ãããŸããªãã
unit, dir ãšããé¢æ°
ãã¯ãã« (a,b) ã«å¯Ÿããunit((a,b)) ã§ãã®æ¹åã®åäœãã¯ãã«ãæ±ããããšãã§ããã
> pair a=(1,1); > write(unit(a)); > (0.707106781186548,0.707106781186548)
plain ãšããããŒã¹ã»ã¢ãžã¥ãŒã«ïŒãšãã« import ã®èŠãªãïŒã«ã¯ã
N, up (0,1) NNE unit(N+NE) NE unit(N+E) ENE unit(E+NE) E, right (1,0) ESE unit(E+SE) SE unit(E+S) SSE unit(S+SE) S,down (0,-1) SSW unit(S+SW) SW unit(S+W) WSW unit(W+SW) W, left (-1,0)
ãšããåäœãã¯ãã«ãå®ããããŠããã
è§åºŠ d ã«å¯Ÿããdir(d) ã§ããã®æ¹åã®åäœãã¯ãã«ãæ±ããããšãã§ãããd ã®åäœã¯ degree ã§ãããã¡ãªã¿ã«ãsin(r) ã cos(r) ã®ãšããr 㯠radian ã ã
> real d=45; //degree > write(dir(d)); (0.707106781186548,0.707106781186547) > write((sin(d*pi/180),cos(d*pi/180))) (0.707106781186547,0.707106781186548)
ãã£ã³ãã¹
picture ãšãããã£ã³ãã¹
æç»ã¯ picture ãšåŒã°ãããã£ã³ãã¹ã«å¯ŸããŠãªããããpicture ã¯
> picture mypic;
ã®ããã«ããŠå®£èšããã
dot ãšããé¢æ°ã¯ pair åããšããpicture ã«æç»ãããã§ã¯ãå ã«çšæãã mypic ã«ç¹ãæã£ãŠã¿ãã
> pair p1, p2; > p1 = (0,0); > p2 = (100,100); > dot(mypic,p1); > dot(mypic,p2);
ã ããããã ãã§ã¯å®éã«äœãæãããªããå³åœ¢ãèŒã£ã picture ã Postscript 座æšãæã€å¹³é¢ã«ã¯ãã€ããŠãåºåããªããšãããªããshipout ãšããé¢æ°ã¯ãpicture ã Postscript 座æšã«ã¯ãã€ããããšã«ããå®éã« EPS åºåãããã
> shipout(mypic);
â» dot ã« äžã€ã® pair ãäžãããšãç¹ãæç»ããããäºã€ã® pair a, bãäžãããšããã¯ãã« a ãšãã¯ãã« b ã®å ç©ãè¿ãã
座æšç³»
åäœïŒãšããã座æšç³»ïŒã«ã€ããŠã¯ãããããæ··ã¿å ¥ã£ãããšããããpicture ã«ãµã€ãºãäžããªãå Žåã¯ãpicture äžã®é·ããè¡šãæ°å㯠shipout æã« Postscript ã®åº§æšç³»ã«ãã£ãŠè§£éããããã€ãŸã Postscript ã«ãã big point(s) ãšããåäœãã€ããŠãããšã¿ãªãããïŒ1 bp = 1/72 inch ã§ããïŒããããã£ãŠãåã®äŸã§æã£ã ç¹ (0,0) ãš ç¹ (100,100) éã®è·é¢ã¯ãsqrt(20000)/72 ã€ã³ãã§åºåããããïŒ sqrt(real) ã¯ã«ãŒã real ãè¿ããïŒ
picture ã«ã¯å€§ãããäžããããšãã§ãããã®å Žåã話ãã¡ãã£ãšéã£ãŠãããããã Metapost ãšã®å€§ããªéãã§ãããšãasymptote ã®å ¬åŒããŒã ããŒãžã«ã¯æžããŠãããå³åœ¢ã®ããããŒã·ã§ã³ãæªããªãç¯å²ã§ãå³åœ¢ã picture ã®å€§ãããã£ã±ãã«ãªãããã«åº§æšç³»ãå®ãŸãã®ã ã
> picture mypic; > size(pic=mypic, 2cm, 1cm); > pair p1, p2; > p1 = (0,0); > p2 = (100,100); > dot(mypic,p1); > dot(mypic,p2); > shipout(mypic);
èµ€åïŒå€ªåïŒã«ããéšåã«ãããmypic ã® x æ¹åãµã€ãºã 2 cm ã«ãy æ¹åã®ãµã€ãºã 1 cm ã«æ±ºãŸãããããŠãããã倧äºãªãšãããªã®ã ãããã®ããã«ãµã€ãºãäžãããšããã® picture ã®äžã«ããå³åœ¢ããæå®ããããµã€ãºã«ãããŸãããã« picture å éšã®åº§æšç³»ã調ç¯ãããã®ã§ããããããã£ãŠãäžã®äŸã§ã¯ãy 軞æ¹åã® 1 cm ããã£ã±ããã£ã±ãã«äœ¿ããx 軞æ¹åã«ã¯äœè£ãæ®ãããŸãŸã1 cm x 1 cm ã®æ£æ¹åœ¢ã®ããããå·Šäžãšå³äžã«äºã€ã®ç¹ãåºåããããïŒããããããšèšã£ãã®ã¯ãå®éã¯å°ãã®ããŒãžã³ãèæ ®ãããæ ãªãïŒã
size ã picture ã«äžããã®ã¯ dot ããåã§ãããããåŸã§ããããshipout ããåãªãã°ãããããsize ã®åŒæ°ã§ pic= ãçç¥ããŠãsize(pic1,1cm,2cm) ã®ããã«ããŠããããsize(pic1,1cm) ãšãããšãsize(pic1,1cm,1cm) ãšåãã§ããããŸããããã« size(1cm, 2cm) ãšãããšãcurrentpictureïŒåŸè¿°ïŒã®ãµã€ãºã 1cm x 2cm ã«æå®ããããsize(pic=pic1,1cm,0) ãšãããšãx 軞æ¹åã« 1cm ã®å¶éããããããããy 軞æ¹åã®ãµã€ãºã¯ç¡å¶éã«ãªãããŸããsize(pic=pic1,0,0) ãšãããšã座æšç³»ãæåã®ç¶æ ã«æ»ãã1 ã 1 bp ãããããããã«ãªããåºåã®å€§ããã«ããããå¶éã解é€ãããã
æ®ããã®å®å¿ã¡ã¢ïŒœãµã€ãºãäžãã picture ã«äžã€ã ãç¹ãæã€ãšãwarning: x scaling in picture unbounded ãšã warning: y scaling in picture unbounded ãšãããèŠåãåºãããããããã¯ã倧ããã®ãªãç¹ãã²ãšã€æã£ãŠ picture ã®ãµã€ãºã«æ¡å€§ããã£ãŠïŒãç¹ã¯å€§ããããªãããæ¡å€§ã§ããªããããªãã§ãããç¡çç¡çããšèšã£ãŠããã®ã§ããã
add ãšããé¢æ°
ãã picture ã®å 容ãå¥ã® picture ã«è¿œå ããããšãã§ãããadd(picture1, picture2 ã«ãã£ãŠãpicture2 ã«èŒã£ãŠããå³åœ¢ããpicture1 ã«è¿œå ã³ããŒãããã
> picture pic1; > size(pic=pic1, 5cm, 5cm); > picture pic2; > size(pic=pic2, 1cm, 1cm); > dot(pic1, (0,0)); > dot(pic1, (100,100)); > dot(pic2, (100,0)); > dot(pic2, (0,100)); > add(pic1, pic2); > shipout(pic1);
äžã®äŸã§ã¯äžèŸº 5 cm ã®æ£æ¹åœ¢ã®åã€ã®è§ã«ç¹ãæãããã座æšç³»ã¯ picture ã«å±ãããã®ã§ãããå³åœ¢ã«å±ãããã®ã§ã¯ãªãã®ã§ãè¿œå ãããå³åœ¢ããã€é·ãã¯ãåäœãªãã®ãŸãŸå æ¹ã«èŒžåºããããããpic2 ã«å¯Ÿãã 1cm x 1cm ãšããæå®ã¯åºåã«åœ±é¿ããŠããªãã
currentpicture ãšãã picture
ãã€ã¯ãcurrentpicture ãšããååã® picture ãæåããçšæãããŠããŠãããŸããŸãªé¢æ°ã«ãããŠãpicture ã®æå®ãçç¥ããå Žåããã©ã«ãã«ãªã£ãŠãããããã«ãdot ãªã©ã®æç»é¢æ°ã§ currentpicture ã察象ãšããå Žåãæç»ããç¬éãæé»ã®ãã¡ã« shipout ãããïŒäžæ¹ãadd ã®å Žåã¯ãdot ã®å Žåãšéã£ãŠãçžæã current picture ã§ãã£ãŠãæé»ã®ãã¡ã« shipout ããããããšã¯ãªããããæ瀺çã«ãããè¡ãå¿ èŠãããïŒã
ãããã£ãŠã
> picture mypicture; > dot(pic=mypicture, (0,0)); > shipout(mypicture);
ãšããã®ã¯ãããã«
> dot((0,0));
ãšããã®ãšåãã§ããã
æ®ããã®äŸ¿å©ã¡ã¢ïŒœè€æ°ã®ãã¯ãã£ãŒãçµ±åãããšãã«å®éçãªæ¹æ³ã¯ãå picture ãããã©ã«ãã® picture ã§ãã currentpicture ã« add ããŠããããšã§ããããããªããadd(pic1); add(pic2) ãšã ãããã°ããããã ã
erase ãšããé¢æ°
picture ã®å 容ãæ¶ãããã«ã¯
> erase(mypicture);
ãšããããã«è¡ãããã ãããã®ãšã座æšç³»ã«ããããæ å ±ã¯æ¶å»ãããªãã座æšç³»ã«ããããæ å ±ãæ¶å»ããããªãã
> erase(mypicture); > size(mypicture,0,0);
ãšããããªããerase ãããã©ã«ãã® picture 㯠currentpicture ã§ããã
æ®ããã®äŸ¿å©ã¡ã¢ïŒœãã£ãããªå³ã察話çã«ã€ãããšãã¯ãpicture backup; ãšãã£ãŠ backup çšã® picture ãçšæããŠãããããã¯ã¢ããããŠããããæç¹ã§ erase(backup); add(backup,currentpicture); ãšãã£ãŠããã°ãããã£ã¡ãŸã£ããŒãã£ãŠãšãã«ãerase(); add(backup); ã§ç°¡åã«åã®ããã¯ã¢ãããŸã§ currentpicture ã®å 容ãæ»ãããšãã§ããã
frame ãšãããã£ã³ãã¹
asymptote ã«ã¯ãpicture ã®ã»ãã« frame ãšããæç»ãã£ã³ãã¹ããããããã¯åžžã« Postscript ã®åº§æšãæããpicture ã®ããã«ãããå€åãããããªãããããã£ãŠãframe äžã®å³åœ¢ã picture ã« add ããŠããããã䌞瞮ããŠåºåããããã¯ããªãããã®ããããã£ãã·ã§ã³ã®æåãå ¥ããŠãããªã©ã®çšéã«çšããããã
ããã㪠frame ã®å®£èšã¯
> frame myframe;
ã®ããã«è¡ãã
次ã¯ãframe ãš picture ã®éããèŠãããã®äŸã// 以åŸã¯ã³ã¡ã³ãã
> picture mypic; > frame myframe; > // currentpicture ã¯ããã©ã«ããªã®ã§ picture currentpicture; ã¯äžèŠ > size(5cm, 5cm); // size(pic=currentpicture, 5cm, 5cm); ãšåãããš > dot(mypic,(0,0)); > dot(mypic,(10,10)); > dot(myframe,(0,10)); > dot(myframe,(10,0)); > add(mypic); // add(currentpicture, mypic); ãšåãããš > add(myframe); // add(currentpicture, myframe); ãšåãããš warning: y scaling in picture unbounded
mypic äžã® 2 ç¹ã¯ã茞åºçžæã® currentpicture ã®ãµã€ãºã«åãããŠåºãããã ãåºãã£ãŠåºåãããïŒpicture ã®å³äžç«¯ãå·Šäžç«¯ãžäºç¹ïŒããmyframe ã®äžã® 2 ç¹ã¯ã茞åºãããŠãæåã«äžãããã座æšãã€ãŸãã(0 bp, 10 bp) ãš (10 bp, 0 bp) ãåŸçŸ©ã«å®ã£ãŠåºåãããŠããïŒå·Šäžä»è¿ã®å¥ã®äºç¹ïŒããšããããã
ãããã®å®å¿ã¡ã¢ïŒœframe ã®å 容ãã倧ãããäžãã picture ã« add ãããšããwarning: x scaling in picture unbounded ãšã warning: y scaling in picture unbounded ãšãããèŠåãåºãããšããããframe ã«æç»ãããã®ã¯ãµã€ãºãæ〠picture ã«ã¯ãã€ããŠã䌞瞮ããªãããããå³åœ¢ããããã®èããŠããµã€ãºããã¯ã¿åºãããããšèšã£ãŠããã®ã§ããã
æ²ç·ãšçŽç·
path ãšãããã®
path ã¯ããŒããšãã³ã³ãããŒã«ã»ãã€ã³ãã®åã«ãã£ãŠãããžãšæ²ç·ïŒãã®ç¹æ®ãªã±ãŒã¹ãšããŠã®çŽç·ãå«ãïŒãè¡šçŸãããã®ã§ãããïŒãã®ã¡ã¢ã§ã¯ããžãšæ²ç·ãšããã° 3 次ã®ããžãšæ²ç·ãæãããšã«ããïŒ
ã§ã¯ãpath ã«ã€ããŠèŠãããŸãã
> pair a=(0,0); > pair b=(0.5,1); > pair c=(1,0);
ã®ãããªäžç¹ã®ããŒãåè£ã«å ãã
> pair p1=(-0.309017,0.412023); > pair p2=(-0.0150283,1); > pair p3=(1.01503,1); > pair p4=(1.30902,0.412023);
ã®ãããªã³ã³ãããŒã«ã»ãã€ã³ãåè£ãäœæããŠããã
å ã«ç€ºããŠãããšã次ã®å³ã®ãããªããšãããããã®ã§ããã
ãã®ããã«ã¯ããŸãã
> path mypath;
ã®ããã« path ã宣èšãããã€ãã«ã
> mypath=(a..controls p1 and p2..b..controls p3 and p4..c); > write(mypath); // ä»£å ¥ãããå 容ãç¢ºèª (0,0).. controls (-0.309017,0.412023) and (-0.0150283,1) ..(0.5,1).. controls (1.01503,1) and (1.30902,0.412023) ..(1,0)
ãã®ããã«ãããŒãããããã pair ã®éã«ã³ã³ãããŒã«ã»ãã€ã³ããã¯ããã 圢㧠path ãèšè¿°ããä»£å ¥ããŠããã°ããã
path ãæç»ããã«ã¯ã
> size(5cm); > draw(mypath);
ã®ããã«ããã
ãªããdraw ã dot ãšåãã§ãããã©ã«ãã® picture 㯠currentpicture ã§ããããããŠããã®å Žåãæç»ããããšåæã«æé»ã®å ã« shipout ãããã
ç·åããããã path
ç·åããããã path ã¯ãäžè¬ã«ããžãšæ²ç·ããããããã¹ã®ç¹æ®ãªã±ãŒã¹ã«éããªãã
> pair a=(0,0); > pair b=(1,1); > pair p1=(0.333333,0.333333); > pair p2=(0.666667,0.666667); > picture mypic; > size(mypic, 5cm, 5cm); > dot(a,red); > dot(b,red); > dot(p1,blue); > dot(p2,blue); > path mypath=(a..controls p1 and p2..b); > draw(mypic, mypath); > shipout(mypic);
ïŒäžã®å³ã§ãç¹ã«ã€ããã©ãã«ã¯ãå¥ã®ã¢ããªã±ãŒã·ã§ã³ã§ã€ã足ãããã®ãïŒ
ã³ã³ãããŒã«ã»ãã€ã³ãããªã path ãäœãã°ç·åãåŒããã®ã§ã¯ãªãããšæããããããªãããããã¯èš±ãããªããpath ã®ããŒãã¯éæŸããã端ç¹ã§ã¯å åŽã«äžã€ããã以å€ã§ã¯ååŸã«äžã€ã®ã³ã³ãããŒã«ã»ãã€ã³ããæããªããŠã¯ãªããªããäžæºã«æãåãã¯ãguide ã®é ãèŠããšäºè§£ãããã ããã
éãã path
path ãéããã«ã¯ãæåŸã« ..cycle ãšããã®ãã€ããã°ãããpath ãéãããšãã³ã³ãããŒã«ã»ãã€ã³ãããpath ãéããŠããªããšããã 2 ã€äœèšã«å¿ èŠã«ãªãã
> pair a=(1,0); > pair b=(0,1); > pair c=(-1,0); > pair p1=(1,0.5); > pair p2=(0.5,1); > pair p3=(-0.5,1); > pair p4=(-1,0.5); > pair p5=(-1,-0.5); > pair p6=(1,-0.5); > mypath=(a..controls p1 and p2..b..controls p3 and p4..c..controls p5 and p6..cycle); > size(5cm); > draw(mypath);
è£éºïŒpath ãé£ãé¢æ°
guide ãšãããã®
ã³ã³ãããŒã«ã»ããŒããèªåã§äœæããªããšç·åäžæ¬åŒããªããšããã®ã§ã¯å°ããããããguide ãšãããã®ãããããå¿é ãªããguide ã¯ãããŒããã¡ã®äœçœ®ãæã£ãŠããç¹ã§ã¯ path ãšåãã§ãããããããpath ãšç°ãªãã³ã³ãããŒã«ã»ãã€ã³ãããããæãããasymptote ããããããä»»ãã§ãã¹ãäœæããŠãããã
guide ã¯æ¬¡ã®ããã«å®£èšããã
> guide myguide;
ãã³ãããŸã£ããäžããªããšãã® guide ã®æžãæ¹ã¯ã
> pair a=(0,0); > pair b=(0.5,1); > pair c=(1,0); > myguide = (a..b..c);
ã®ãããªãã®ã ã
guide ã path ã«å€æããã®ã¯ãæé»ã®ãã¡ã«è¡ããããããšãã°ã
> path mypath=myguide;
ã®ããã«ä»£å ¥ããŠãããšããã£ã¹ããããçµæãmypath ã«ãã¹ãå ¥ã£ãŠããã
> write(mypath); (0,0).. controls (-0.309017,0.412023) and (-0.0150283,1) ..(0.5,1).. controls (1.01503,1) and (1.30902,0.412023) ..(1,0)
4 ã€ã®ã³ã³ãããŒã«ã»ãã€ã³ããèªåçã«èšç®ãããŠããã®ãããããããšã¯ããããŒã«ã
> draw(mypath);
ãšãããšãæç»ã§ããã
ïŒäžã®å³ã¯ããããããããã«ãããŒããšã³ã³ãããŒã«ã»ãã€ã³ããæã蟌ãã§ãããïŒ
ã¡ãªã¿ã«ïŒãšããããå®çšäžå€§äºãªç¹ã ãïŒguide ãã path ãžã®æé»ã®ãã£ã¹ãã¯ãdraw( ) é¢æ°ã®åŒæ°ãšã㊠path ã®ãããã« guide ãé£ããããšãã«ãèµ·ãããããå ã»ã©ã®äŸã§ãããªããã¯ãããã
> draw((a..b..c));
ãšãã£ãŠããçµæã¯åãããã
ãããŸã§åæã«ãããããšãäžäœã©ããã£ãŠã³ã³ãããŒã«ã»ãã€ã³ããèšç®ããšãã®ããšããããšãæ°ã«ãªã£ãŠãããããã¥ã¢ã«ã«ãããšãasymptote ã guide ãã path ãåŸãããã®æ¹æ³ã¯ãDonald Knuth ã® å°è«æ The MetaFontbook ã® Chapter 14 ã«æžããŠãããã®ã ããã ãã©ãããã極åå匧ã«è¿ã¥ããšããæ¹éãããã
ãšããã§ãå匧ã£ãœããã®ä»¥å€ã¯ guide ã䜿ã£ãŠæããªãã®ããšãããšãããã§ã¯ãªãããŠãŒã¶ã¯ã©ã®ããã«ããŒããè£éãããïŒã³ã³ãããŒã«ã»ããŒããã©ãã«äœæãããïŒã«ãããããã³ãã guide ã«å«ããŠããããšãã§ããã
guide ã«èšãããšã®ã§ããè£éã®ããã®ãã³ãã¯ïŒçš®é¡ãããtension,direction,curl ã ã
tension ã¯ãã¹ãã©ã€ã³æ²ç·ã®ãã³ã·ã§ã³ãå®ãããã®ã ããã§ãããŒããçµã¶æ²ç·ãã©ã®ãããããããã«ããã瀺ã倧ããã§ãæ°åã倧ããã»ã©çŽç·ã«è¿ããªããšãããïŒæ£çŽã«ãããšãç§ã¯ãããã©ãããä»çµã¿ãªã®ãç解ããŠããªããã ïŒã0.75 以äžã®å®æ°ãæå®ã§ããããã©ã«ã㯠1ãtension ã¯ãäžã€ã®ã»ã°ã¡ã³ãïŒäžé£ã® path ã®äžã§ãµãã€ã® node ã«ã¯ããŸããéšåïŒã«ã€ããŠäºã€æå®ã§ããã
nodeA..tension 1 and 2..nodeB nodeA..tension 1 ..nodeB
ãšããæžãæ¹ãã§ãããtension ãäžã€ããæå®ãããŠããªããšãã¯ãäž¡æ¹ã«åãå€ãäžãããããšèŠãªãããã
> pair a=(0,0); > pair b=(0.5,1); > pair c=(1,0); > dot(a); dot(b); dot(c); > draw((a..tension 0.75 and 0.75 ..b..tension 0.75 and 0.75 ..c),blue); > draw((a..tension 1 and 1 ..b..tension 1 and 1 ..c)); > draw((a..tension 2 and 2 ..b..tension 2 and 2 ..c),red);
direction ã¯ãããŒããšã³ã³ãããŒã«ãã€ã³ããé²è¡æ¹åã«çµã¶ãã¯ãã«ãšåãæ¹åã®åäœãã¯ãã«ã(0,1) ã§ãããã unit(1,1) ãšã dir(45) ã§ãããã
éæŸããããã¹ã®ç«¯ç¹ä»¥å€ã¯äžã€ã®ããŒãã«ã€ããäºã€ã® direction ãæžãããšãã§ããéæŸããããã¹ã®ç«¯ç¹ã§ã¯äžã€ã® direction ãæžãããšãã§ããããŸãããããã direction ã¯ãå šãæžããªããŠãããŸããªãã
å ·äœçãªæžãæ¹ã¯ã
{dir(45)}nodeA{dir(-45)} {dir(45)}nodeA nodeA{dir(-45)} nodeA
ã®åŠãã
size(5cm); pair a=(0,0); pair b=(0.5,1); pair c=(1,0); pair b1=unit((1,1/2)); pair b2=unit((1,1/2)); path mypath=(a..{b1}b{b2}..c); draw(mypath);
äžã®äŸã§ã¯ ç¹ a, b, c ã®äœçœ®ãšãç¹ b ã«ãããäºã€ã®ãã³ãã«ã®æ¹åãå®ããŠæç»ããã
ãªããdirection ãšããŠæå®ãããã¯ãã«ã®åãã«æ³šæã
ïŒäžã®å³ã¯ããããããããã«ãããŒããšã³ã³ãããŒã«ã»ãã€ã³ããæã蟌ãã§ãããïŒ
curl ã¯ã端ç¹ããŒãã®æ²çãäžããã æ°å€ã倧ããã»ã©ãæ²ããããã¯ãããã0 ããçã£çŽãã§ã1 ããåã£ãœããã§ãããããã©ã«ã㯠1 ã§ãããå ·äœçãªæžãæ¹ã¯ã
{curl 0.5}nodeA{curl 0.5} {curl 0.5}nodeA nodeA{curl 0.5} nodeA
ã®åŠãã
size(5cm); pair a=(0,0); pair b=(0.5,1); pair c=(1,0); label("a",a,S); label("b",b,N); label("c",c,S); draw ((a{curl 0}..b..{curl 0}c),blue); draw ((a{curl 1}..b..{curl 1}c)); draw ((a{curl 10}..b..{curl 10}c),red);
äºã€ã®ããŒãã«ã¯ããŸããã²ãšã€ã®ã»ã°ã¡ã³ãã®äž¡åŽã« curl ãæå®ãããå Žåãcurl ã®å€ã«é¢ä¿ãªããã®ã»ã°ã¡ã³ãã¯çã£çŽã«ãªãããŸããcurl 㯠direction ãšäž¡ç«ããªãã
ç·åããããã guide
ããããã«ã
> size(2cm); > pair a=(0,0); > pair b=(1,1); > pair c=(2,0);
direction ã䜿ãå Žåã¯ã
> guide myguide=(a{unit(b-a)}..{unit(b-a)}b{unit(c-b)}..{unit(c-b)}c); > draw(myguide);
curl ã䜿ãå Žåã¯ã
> guide myguide=(a{curl 0}..{curl 0}b{curl 0}..{curl 0}c); > draw(myguide);
äžã€ã®ã»ã°ã¡ã³ãã®äž¡ç«¯ã« curl ãèšå®ãããŠãããªããcurl ã®å€ã«é¢ä¿ãªããã®ã»ã°ã¡ã³ãã¯çã£çŽã«ãªããããcurl ã®å€ã¯äœã§ãããã
ã§ãåãæãç·ãæãããšãã§ãããa-b, b-c éã«ããŒããã¯ããŸããªããããtension ãããã€ã§ãã£ãŠãïŒã€ãŸãããã©ã«ãã® 1 ã§ãã£ãŠãïŒãçã£çŽãªç·ã«ãªãã
æãç·ããããã (a{curl 1}..{curl 1}b{curl 1}..{curl 1}c) ãšãã guide ã (a--b--c) ãšæžãããšãã§ããéåžžã«ãã°ãã°çšãããããããã¯ãããããã®ãã¥ãŒããªã¢ã«ã®æåã«èšãããŠããè¡šçŸã§ããã
éãã guide
éãããã¹ã«è§£æ±ºãããããã« guide ãæžãããã«ã¯ãpath ã®å Žåãšåæ§ã--cycle ãšããã®ãæåŸã«ã€ããŠããã°ããã
åºæ¬çãªå³åœ¢
é·æ¹åœ¢ã»æ£æ¹åœ¢
unitsquare
unitsquare ãšãã guide ãçšæãããŠãããå西端ã (0,0) ã«ãã€äžèŸº 1 ã®æ£æ¹åœ¢ã§ããããã°ãã°ããã transform ã§ã¢ãã£ã³å€æããŠãä»»æã®é·æ¹åœ¢ãæãã®ã«çšããã
> write(unitsquare); (0,0) {curl 1}..{curl 1}(1,0) {curl 1}..{curl 1}(1,1) {curl 1}..{curl 1}(0,1) {curl 1}..{curl 1}cycle
ã®ããã«ããŠèŠãŠã¿ããšãã»ã°ã¡ã³ãã®äž¡ç«¯ã« curl ãæå®ããããšã«ãããçã£çŽãªç·ãåŸãŠããããšããããã
path ã«è§£æ±ºãããåŸã®ããŒããšã³ã³ãããŒã«ã»ãã€ã³ããæããŠã¿ããšã
ã®ããã«ç¢ºèªã§ããã
åã»å匧
åãå匧ãäžè¬ã® path ã«ãã£ãŠè¡šçŸãããç¹å¥ãªãã®ã§ã¯ãªãã
unitcircle ãšãããäžå¿ (0,0) ã§ååŸ 1 ã®åããããã guide ãçšæãããŠããã®ã§ãäŸãšããŠãããèŠãŠã¿ãã
> write(unitcircle) (1,0) ..(0,1) ..(-1,0) ..(0,-1) ..cycle
ããããæ±è¥¿ååã® 4 ç¹ãããŒãã«æã€ããžãšæ²ç·ã§ãããpath ã«è§£æ±ºããããã®ã§ãããŒããšã³ã³ãããŒã«ã»ãã€ã³ããæããŠã¿ããšã