2. http://nhdien.wordpress.com - Nguyễn Hữu Điển 2
1 Giới thiệu gói lệnh
Có hai gói lệnh để thể hiện trục tọa độ, coordsys.sty cho tọa độ đề các, còn logsys.sty cho hệ
tọa độ cực lấy ở:
http://tug.ctan.org/tex-archive/macros/latex/contrib/coordsys/
2 Trục tọa độ vuông góc
Dùng gói lệnh coordsys.sty có ba tùy chọn usepackage[<tùy chọn>]{coordsys}. <tùy chọn>
là đường chia độ centred (mặc định), outside, và inside.
2.1 Tọa độ một chiều
Lệnh numbline vẽ đường thẳng trong môi trường picture.
begin{picture}(200,20)(-75,-15)
numbline{-75}{125}
end{picture}
-
−50 0 50 100
Chia độ trên đường thẳng là 10, để thay đổi chia vạch ta cho tùy chọn ví dụ là [7]
numbline[7]{-75}{125}
-
−70 −35 0 35 70 105
Lệnh có * không đánh số
numbline*[7]{-75}{125}
-
Tương tự cho lệnh đường trục đứng vnumbline, vnumbline*
6
50
100
vnumbline{20}{120}
2.2 Tọa độ hai chiều
Lệnh coordsys tạo ra hệ tọa độ với hai đối số cho trục
begin{picture}(200,110)(-50,-50)
coordsys(-50,-50)(150,60)
put(75,25){texttt{textbackslash coordsys(-50,-50)(150,60)}}
end{picture}
3. http://nhdien.wordpress.com - Nguyễn Hữu Điển 3
-
6
−50 50 100
−50
50
coordsys(-50,-50)(150,60)
Lệnh coordsys* và tùy chọn [độ dài] trên hai trục không có số và chia lại.
Lệnh fcoordsys và fcoordsys* vẽ hệ tọa độ theo khung hình chữ nhật
begin{picture}(220,125)(30,35)
fcoordsys[5](50,50)(250,160)
put(155,125){texttt{textbackslash fcoordsys[5](-50,-50)(150,60)}}
end{picture}
-
6
50 75 100 125 150 175 200 225
50
75
100
125
150
fcoordsys[5](-50,-50)(150,60)
Lệnh bcoordsys và bcoordsys* vẽ hệ tọa độ theo khung hình chữ nhật
begin{picture}(265,125)(-70,-65)
bcoordsys[15][5](-50,-50)(195,60)
put(-30,25){texttt{textbackslash bcoordsys[15][5](-50,-50)(195,60)}}
end{picture}
0 75 150
−50
−25
0
25
50
bcoordsys[15][5](-50,-50)(195,60)
Lệnh window và window* vẽ hệ tọa độ theo khung hình chữ nhật
begin{picture}(302,127)(-107,-67)
window(-50,-50)(195,60)
put(15,25){texttt{textbackslash window(-50,-50)(195,60)}}
end{picture}
4. http://nhdien.wordpress.com - Nguyễn Hữu Điển 4
xmin = −50 xmax = 195
ymin = −50
ymax = 60 6
-
window(-50,-50)(195,60)
Ta dùng lệnh lưới để vẽ tọa độ coordgrid
begin{picture}(300, 125)
coordgrid(0,0)(300,125)
put(15,25){texttt{textbackslash coordgrid(0,0)(300,125)}}
end{picture}
coordgrid(0,0)(300,125)
và lồng tọa độ vào
begin{picture}(245,110)(-50,-50)
coordgrid[15][5](-50,-50)(195,60)
coordsys[15][5](-50,-50)(195,60)
end{picture}
-
6
75 150
−50
−25
25
50
2.3 Gán nhãn
Lệnh setvlabel đặt nhãn
numbline{-75}{125}
put(125,0){sethlabel{x}}
-
−50 0 50 100 x
5. http://nhdien.wordpress.com - Nguyễn Hữu Điển 5
2.4 Chia độ đậm dày
Lệnh hthickratio và vthickratio.
renewcommand{hthickratio}{4}
numbline[25]{0}{350}
-
0 100 200 300
2.4.1 Hai trục có độ chia khác nhau
unitlength đặt lại cách chia đơn vị và
-
6
−10 −5 5 10
50
100
rescaleby{10}{1}{vlabel}
coordsys[1](-10,0)(12,12)
đặt lại
renewcommand{hthickratio}{6}
rescaleby[pi]{1}{180}{hlabel}
rescaleby{1}{100}{vlabel}
coordsys[15][10](0,-100)(400,115)
put(90,50){circle{6}}
-
6
π
2 π 3
2 π 2π
−1
−1
2
1
2
1
2.5 Loại đánh dấu khác nhau
tickstyle{thinlinesrenewcommand{ticklength}{4pt}}
{thinlinesrenewcommand{ticklength}{8pt}}
-
−50 0 50 100
Đánh dấu theo coordsys hoặc outside.
usepackage[outside]{coordsys}
6. http://nhdien.wordpress.com - Nguyễn Hữu Điển 6
-
6
−50 50 100
−500
500
3 Đặt hình vào tọa độ
Dùng Maple để vẽ và lấy số liệu vào. Ví dụ vẽ hình cho hàm f(x) = x2
10 trong Maple làm
> plot( x^2/10, x=-10..10, title="x^2/10");
> putfile( "parabola.put", % );
Như vậy trong tệp parabola.put chứa các tọa độ và dùng gói lệnh epic và eepic:
setlength{unitlength}{7pt}
begin{picture}(21,13)(-10,-2)
coordsys[1](-10,0)(11,11)
putfile{parabola.put}{picsquare}
end{picture}
-
6
−10 −5 5 10
50
100
Vẽ liền nét
setlength{unitlength}{7pt}
begin{picture}(21,13)(-10,-2)
coordsys[1](-10,0)(11,11)
begin{drawjoin}
letput=jput
putfile{parabola.put}{picsquare}
end{drawjoin}
end{picture}
-
6
−10 −5 5 10
50
100
Tương tự vẽ đường bậc ba và các hàm khác
Trong Maple:
7. http://nhdien.wordpress.com - Nguyễn Hữu Điển 7
> plot( (x+2)*(x-1)*(x-2), x=-3..4 );
> putfile( "cubic.put", %, scale=[10, 1] );
rescaleby{1}{10}{hlabel}
coordsys[2](-30,-20)(40,36)
begin{drawjoin}
letput=jput
putfile{cubic.put}{picsquare}
end{drawjoin}
-
6
−3 −2 −1 1 2 3
−200
−100
100
200
300
4 Kết luận
Cách làm này rất hay để vẽ hình vào TeX, sử dụng Maple không khó, lấy tệp dữ liệu vào hình
theo các phiên bản mới của Maple hơi khác tôi sẽ viết lại bài này sau. Các bạn khai thác kiểu
này có rất nhiều thú vị.
Trong Maple:
> polarplot( 1+sin(theta), theta=0..2*Pi );
> putfile( "cardioid.put", %, scale=[100,100] );
Trong LATEX:
rescaleby{1}{100}{hlabel}
rescaleby{1}{100}{vlabel}
coordsys(-130,-25)(130,215)
begin{drawjoin}
letput=jput
putfile{cardioid.put}{picsquare}
end{drawjoin}
-
6
−1 −1
2
1
2 1
1
2
1
3
2
2