Forgot password?
 Create new account
View 5969|Reply 9

tikz画双曲线

[Copy link]

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2013-8-29 22:19:40 |Read mode
画圆有 circle,画椭圆有 ellipse,两者都可以用 arc 来画部分的弧,抛物线也有 parabola 什么的(一直没用过),就没有双曲线,好像也没什么好办法,目前我都是用参数方程来画,即 $x=a\sec\theta$, $y=b\tan\theta$。
画的时候变量范围要注意,由于涉及无穷大,tikz 的计算似乎也不会自动解决奇点问题,所以不能一次性画完两支,得分开来画,而且变量不要接近 $\pi/2+k\pi$,否则图会很大。
例:
  1. \begin{tikzpicture}[smooth]
  2. \def\a{0.8}
  3. \def\b{2/3}
  4. \draw[domain=-70:70] plot ({\a*sec(\x)},{\b*tan(\x)});
  5. \draw[domain=110:250] plot ({\a*sec(\x)},{\b*tan(\x)});
  6. \end{tikzpicture}
Copy the Code
效果自行试之……

801

Threads

4889

Posts

310K

Credits

Credits
36169

Show all posts

isee Posted at 2013-8-31 22:48:14
没细看,不过,画过反比例函数,用TiKZ用具体的解析式画一个,没什么太大的困难

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2013-8-31 23:03:40
没细看,不过,画过反比例函数,用TiKZ用具体的解析式画一个,没什么太大的困难 ...
isee 发表于 2013-8-31 22:48

画反比例函数也是要分开两段来画啊,一定遇到分母为0,tikz不能处理。

0

Threads

3

Posts

16

Credits

Credits
16

Show all posts

zwl1972 Posted at 2013-9-1 21:33:24
  1. \begin{tikzpicture}[scale=0.4,line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
  2. \draw[-latex,color=black,thick] (-7.42,0) -- (13,0) node[above] {$x$};
  3. \draw[-latex,color=black,thick] (0,-6.21) -- (0,9)node[right] {$y$};
  4. \draw[color=black] (0pt,-10pt) node[right] {\footnotesize $O$};
  5. \clip(-7,-6) rectangle (12,5);
  6. \draw[smooth,samples=100,domain=-pi:pi,thick,variable=\t] plot({2*sec((\t r))},{sqrt(2)*tan((\t r))});
  7. \end{tikzpicture}
Copy the Code

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2013-9-1 21:55:44
回复 4# zwl1972

这么神奇?\clip 一下就不会出问题而且还把渐近线也画了出来?

0

Threads

3

Posts

16

Credits

Credits
16

Show all posts

zwl1972 Posted at 2013-9-1 22:46:16
回复 5# kuing
记得是输入一道高考题的时候偶然发现的

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2013-9-1 22:49:54
看来还有待了解tikz的内部运作……

801

Threads

4889

Posts

310K

Credits

Credits
36169

Show all posts

isee Posted at 2013-9-22 11:25:51
学习4楼了。

回楼上,TiKZ手册就 700多页,可以想像的……

==

现在运行了,原来,是用参数法画的——

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2022-2-17 23:33:19
Last edited by hbghlyj at 2022-2-17 23:41:00原来是这样! 我把ggb2tikz的小程序修改一下

但是能不能不画渐近线

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2022-2-18 01:18:50
回复 9# hbghlyj

其实将 sample 改小点,不 clip,就能知道为什么 4# 的画法会出现“渐近线”。
  1. \begin{tikzpicture}
  2. \draw[->] (-4,0) -- (4,0);
  3. \draw[->] (0,-4) -- (0,4);
  4. \draw[blue,samples=15,domain=-pi:pi,thick,mark=*] plot({sec(\x r)},{tan(\x r)});
  5. \end{tikzpicture}
Copy the Code

plot 实际上就是在范围内等距取点(samples 个),然后把它们连起来。
为看得更清楚,我在取点处 mark 一下,也不用 smooth,就是折线。
所以那两条其实不是真的渐近线,只不过是两支很远的两点的连线,与渐近线比较接近而已。

手机版Mobile version|Leisure Math Forum

2025-4-20 22:20 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list