HOME > > asymptote <

asymptote <

Asymptote鐚http://asymptote.sourceforge.net/鐚帥祉違c鴻荐茯鐚э式鐚絖у巡擦吾鴻鴻у阪с Metapost c<UNIX, Linux, MacOS, Microsoft Windows уLaTeX 箴絖鐚 LaTeX 綵√ф吾с鐚潟若鐚吾ゃ鐚鴻荀篏帥潟帥潟羈や鴻篁eユ莎激藥c鴻泣ャ若鴻ゃ活障若吟羂ャ<紊ц鐚茵上ユ茯鐚緇 http://oku.edu.mie-u.ac.jp/~okumura/blog/node/2337 ユ茯吾肴障荅鐚

鐚祉潟鐚巡сeゃ<若吾篋冴絎 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 篏睡箴

醇吾c醇吾羂

ゃ潟鴻若

絎吟 http://asymptote.sourceforge.net/ с潟若rpm Linux ゃ glibc ゃ違 asymptote ゃ潟鴻若с若吾с 1.18 ゃ潟鴻若

罔羣c罕

/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

с絲乗宴≪若潟祉c out.eps <ゃ阪(罔羣с) gv ц;腓冴

$ asy unko.asy

<ゃ巡擦茯水翫潟祉c unko.esp с-V 激с潟ゃ<ゃ吾莨若 gv ц;腓冴絲乗宴≪若 asymptote 腟篋

> quit

с

茵憗羲膊

pair 若水

若水 void, bool, int, real, string pair ゃ鋎帥荀絎違≪綛渇√婚罔篏帥祉triple 鐚罨≦

> pair a;   // 絎h鐚鐚藥鐚
> a=(1,2);  // 篁e

сa 絎臂с絎h (0,0) a 篏ャc荀違

> write(a);
(1,2)

桁紊違荅箴<吟阪с write( ) 篏帥

pair 筝ゃ蚊ゃ絎違冴 . 若篏帥

> pair b = (1,2); // 絎h鐚篁e
> 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 絲障篏帥c帥

> write(c*2); // 篋渇
> (6,4)      
> write(c/2); // 篋渇
> (1.5,2)
> write(c*d); // 鐚
> (-9,38)
> write(c/d); // 鐚
> (0.639344262295082,0.0327868852459016)

pair ゃ茲膣違cсャ蕁 pair 莨若т戎

腟莨若水違 pi

> write(pi)
3.14159265358979

transform

(a,b,c,d,e,f) transform с (x, y) pair 綏≪c喝сゃ障

|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) 吾c荀 (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)

c潟

picture c潟

祉 picture 若違c潟鴻絲障picture

> picture mypic;

絎h

dot ∽ pair picture 祉с mypic 鴻c帥

> pair p1, p2;
> p1 = (0,0);
> p2 = (100,100);
> dot(mypic,p1);
> dot(mypic,p2);

с絎篏喝就莠c picture Postscript 綺фゅ抗≪ゃ阪shipout ∽picture Postscript 綺фゃ絎 EPS 阪

> shipout(mypic);

dot 筝ゃ pair 筝鴻祉篋ゃ pair a, b筝 a b 腥菴

綺ф膤

篏鐚綺ф膤誌ゃ羞激水ャcpicture 泣ゃ冴筝翫picture 筝激茵医 shipout Postscript 綺ф膤祉c茹iゃ障 Postscript big point(s) 篏ゃ帥鐚1 bp = 1/72 inch с鐚c箴фc (0,0) (100,100) 莊≪sqrt(20000)/72 ゃ潟у阪鐚 sqrt(real) 若 real 菴鐚

picture 紊с筝с翫荅宴<cc Metapost 紊ссasymptote 綣若若吾吾喝就若激с潟罩膀蚊с喝就 picture 紊сc宴綺ф膤祉絎障

> 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 綺ф膤祉茯睡сc筝箴сy 荵御劫 1 cm c宴c宴篏帥x 荵御劫篏茖罧障障1 cm x 1 cm 罩f劫就綏筝劽篋ゃ鴻阪鐚荐c絎絨若吾潟鐚

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 阪紊с狗茹iゃ

鐚紙絎綽<鐚純泣ゃ冴筝 picture 筝ゃ鴻ゃwarning: x scaling in picture unbounded warning: y scaling in picture unbounded 茘冴紊с鴻蚊ゆc picture 泣ゃ冴≦ぇc鐚鴻紊с≦ぇсс∞∞荐cс

add ∽

picture 絎鴻ャ picture 菴遵сadd(picture1, picture2 cpicture2 莠c喝就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 罩f劫就ゃ茹鴻綺ф膤祉 picture 絮с喝就絮сс菴遵喝就ら激篏障上鴻莠後冴pic2 絲障 1cm x 1cm 絎阪綵演帥

currentpicture picture

ゃcurrentpicture picture 障障∽違picture 絎ャ翫cdot 脂∽違 currentpicture 絲乗院翫祉藥< shipout 鐚筝鴻add 翫dot 翫c御 current picture сc藥< shipout 腓榊茵綽荀鐚

> picture mypicture;
> dot(pic=mypicture, (0,0));
> shipout(mypicture);

> dot((0,0));

с

鐚紙箴水<鐚処違c若腟怨絎号 picture picture с currentpicture add сadd(pic1); add(pic2) 違

erase ∽

picture 絎鴻羔

> erase(mypicture);

茵綺ф膤祉宴羔サ綺ф膤祉宴羔サ

> erase(mypicture);
> size(mypicture,0,0);

erase picture currentpicture с

鐚紙箴水<鐚純c潟絲乗援ゃpicture backup; c backup picture ≪鴻 erase(backup); add(backup,currentpicture); c違c<障c若cerase(); add(backup); х亜≪障 currentpicture 絎鴻祉с

frame c潟

asymptote picture 祉 frame 祉c潟鴻絽吾 Postscript 綺фpicture 紊cframe 筝喝就 picture add 篌悟軒阪c激с潟絖ャ

frame 絎h

> 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 泣ゃ冴綺綺c阪鐚picture 劽腴綏筝腴娯刻myframe 筝 2 鴻莠後冴筝綺фゃ障(0 bp, 10 bp) (10 bp, 0 bp) 緇臂絎c阪鐚綏筝篁菴ャ篋刻

鐚祉絎綽<鐚frame 絎鴻紊с筝 picture add warning: x scaling in picture unbounded warning: y scaling in picture unbounded 茘冴frame 祉泣ゃ冴 picture ゃ篌悟軒喝就泣ゃ冴水冴荐cс

牙雁

path

path 若潟潟若祉ゃ潟c吾牙鐚号宴若鴻雁鐚茵憗с鐚<≪с吾牙 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 絎hゃ

> mypath=(a..controls p1 and p2..b..controls p3 and p4..c);
> write(mypath);  // 篁eャ絎鴻腆肴
(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 荐菴違篁eャ違

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 荀篋茹c

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 若<篏臀c鴻с path сpath 違潟潟若祉ゃ潟asymptote 篁祉с鴻篏

guide 罨<絎h

> guide myguide;

潟障c鋇 guide 吾鴻

> pair a=(0,0);
> pair b=(0.5,1);
> pair c=(1,0);   
> myguide = (a..b..c);

guide path 紊藥<茵違

> path mypath=myguide;

篁eャc鴻腟mypath 鴻ャ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)

4 ゃ潟潟若祉ゃ潟荐膊若

> draw(mypath);

祉с

鐚筝潟若潟潟若祉ゃ潟莨若с鐚

<帥鐚絎筝紊т鴻鐚guide path 吾藥c鴻draw( ) ∽違綣違 path guide 蕋莎激祉箴с

> draw((a..b..c));

c腟

障у筝篏c潟潟若祉ゃ潟荐膊羂cャ≪asymptote guide path 緇号Donald Knuth 絨顇 The MetaFontbook Chapter 14 吾罐球綣с菴ャ拷

с綣сc純篁ュ guide 篏帥cс若吟若茖鐚潟潟若祉若篏鐚潟 guide с

guide 荐с茖潟鐚腮蕁tension,direction,curl

tension 鴻ゃ恰牙潟激с潟絎с若腟倶牙腓冴紊сс医紊с祉雁菴鐚罩g眼腱篁腟帥茹c鐚0.75 篁ヤ絎違絎с 1tension 筝ゃ祉違<潟鐚筝c 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 g眼с1 c純с 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 ゃ≫祉違<潟g眼障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 ゃ≫祉違<潟g眼curl ゃ篏с

с膩сa-b, b-c 若障tension ゃсc鐚ゃ障 1 сc鐚g眼膩

膩 (a{curl 1}..{curl 1}b{curl 1}..{curl 1}c) guide (a--b--c) 吾с絽吾違ャ若≪荐茵憗с

guide

鴻茹f浦 guide 吾path 翫罕--cycle 緇ゃ違

堺喝就

傑劫就紙f劫就

unitsquare

unitsquare guide 茱睡 (0,0) や莨 1 罩f劫就с違違 transform с≪c喝篁紙傑劫就

> 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 絎g眼膩緇

path 茹f浦緇若潟潟若祉ゃ潟帥

腆肴с

糸綣

綣с筝 path c茵憗劫ャс

unitcircle 筝綽 (0,0) у緇 1 guide с箴荀帥

> write(unitcircle)
(1,0)
..(0,1)
..(-1,0)
..(0,-1)
..cycle

沿タ 4 鴻若ゃ吾牙сpath 茹f浦с若潟潟若祉ゃ潟帥

罨≠
HOME


紕膣
薤藕

茯絖
沿
ユ茯


遵医