找回密码
 快速注册
搜索
查看: 19|回复: 2

kroki.io也支持TikZ 通过 url 参数

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2024-9-2 10:36 |阅读模式
kroki.io/#support
在此表中许多行,包含一行TikZ
Screenshot 2024-09-02 103541.png

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-9-2 10:38

tikz-3dplot 测试


  1. \documentclass{article}
  2. \usepackage{tikz}
  3. \usepackage{tikz-3dplot}
  4. \usetikzlibrary{math}
  5. \usepackage[active,tightpage]{preview}
  6. \PreviewEnvironment{tikzpicture}
  7. \setlength\PreviewBorder{0.125pt}
  8. \begin{document}
  9.   \tdplotsetmaincoords{80}{120}
  10.   %
  11.   \begin{tikzpicture}[tdplot_main_coords,scale=0.75]
  12.     % Indicate the components of the vector in rectangular coordinates
  13.     \pgfmathsetmacro{\ux}{4}
  14.     \pgfmathsetmacro{\uy}{4}
  15.     \pgfmathsetmacro{\uz}{3}
  16.     % Length of each axis
  17.     \pgfmathsetmacro{\ejex}{\ux+0.5}
  18.     \pgfmathsetmacro{\ejey}{\uy+0.5}
  19.     \pgfmathsetmacro{\ejez}{\uz+0.5}
  20.     \pgfmathsetmacro{\umag}{sqrt(\ux*\ux+\uy*\uy+\uz*\uz)} % Magnitude of vector $\vec{u}$
  21.     % Compute the angle $\theta$
  22.     \pgfmathsetmacro{\angthetax}{pi*atan(\uy/\ux)/180}
  23.     \pgfmathsetmacro{\angthetay}{pi*atan(\ux/\uz)/180}
  24.     \pgfmathsetmacro{\angthetaz}{pi*atan(\uz/\uy)/180}
  25.     % Compute the angle $\phi$
  26.     \pgfmathsetmacro{\angphix}{pi*acos(\ux/\umag)/180}
  27.     \pgfmathsetmacro{\angphiy}{pi*acos(\uy/\umag)/180}
  28.     \pgfmathsetmacro{\angphiz}{pi*acos(\uz/\umag)/180}
  29.     % Compute rho sin(phi) to simplify computations
  30.     \pgfmathsetmacro{\costz}{cos(\angthetax r)}
  31.     \pgfmathsetmacro{\sintz}{sin(\angthetax r)}
  32.     \pgfmathsetmacro{\costy}{cos(\angthetay r)}
  33.     \pgfmathsetmacro{\sinty}{sin(\angthetay r)}
  34.     \pgfmathsetmacro{\costx}{cos(\angthetaz r)}
  35.     \pgfmathsetmacro{\sintx}{sin(\angthetaz r)}
  36.     % Coordinate axis
  37.     \draw[thick,->] (0,0,0) -- (\ejex,0,0) node[below left] {$x$};
  38.     \draw[thick,->] (0,0,0) -- (0,\ejey,0) node[right] {$y$};
  39.     \draw[thick,->] (0,0,0) -- (0,0,\ejez) node[above] {$z$};
  40.     % Projections of the components in the axis
  41.     \draw[gray,very thin,opacity=0.5] (0,0,0) -- (\ux,0,0) -- (\ux,\uy,0) -- (0,\uy,0) -- (0,0,0);        % face on the plane z = 0
  42.     \draw[gray,very thin,opacity=0.5] (0,0,\uz) -- (\ux,0,\uz) -- (\ux,\uy,\uz) -- (0,\uy,\uz) -- (0,0,\uz);        % face on the plane z = \uz
  43.     \draw[gray,very thin,opacity=0.5] (0,0,0) -- (0,0,\uz) -- (\ux,0,\uz) -- (\ux,0,0) -- (0,0,0);        % face on the plane y = 0
  44.     \draw[gray,very thin,opacity=0.5] (0,\uy,0) -- (0,\uy,\uz) -- (\ux,\uy,\uz) -- (\ux,\uy,0) -- (0,\uy,0);        % face on the plane y = \uy
  45.     \draw[gray,very thin,opacity=0.5] (0,0,0) -- (0,\uy,0) -- (0,\uy,\uz) -- (0,0,\uz) -- (0,0,0); % face on the plane x = 0
  46.     \draw[gray,very thin,opacity=0.5] (\ux,0,0) -- (\ux,\uy,0) -- (\ux,\uy,\uz) -- (\ux,0,\uz) -- (\ux,0,0); % face on the plane x = \ux
  47.     % Arc indicating the angle $\alpha$
  48.     % (angle formed by the vector $\vec{v}$ and the $x$ axis)
  49.     \draw[red,thick] plot[domain=0:\angphix,smooth,variable=\t] ({cos(\t r)},{sin(\t r)*\costx},{sin(\t r)*\sintx});
  50.     % Arc indicating the angle $\beta$
  51.     % (angle formed by the vector $\vec{v}$ and the $y$ axis)
  52.     \draw[red,thick] plot[domain=0:\angphiy,smooth,variable=\t] ({sin(\t r)*\sinty},{cos(\t r)},{sin(\t r)*\costy});
  53.     % Arc indicating the angle $\gamma$
  54.     % (angle formed by the vector $\vec{v}$ and the $z$ axis)
  55.     \draw[red,thick] plot[domain=0:\angphiz,smooth,variable=\t] ({sin(\t r)*\costz},{sin(\t r)*\sintz},{cos(\t r)});
  56.     % Vector $\vec{u}$
  57.     \draw[blue,thick,->] (0,0,0) -- (\ux,\uy,\uz) node [below right] {$\vec{u}$};
  58.     % Nodes indicating the direction angles
  59.     \pgfmathsetmacro{\xa}{1.85*cos(0.5*\angphix r)}
  60.     \pgfmathsetmacro{\ya}{1.85*sin(0.5*\angphix r)*\costx}
  61.     \pgfmathsetmacro{\za}{1.85*sin(0.5*\angphiz r)*\sintx}
  62.     \node[red] at (\xa,\ya,\za) {\footnotesize$\alpha$};
  63.     %
  64.     \pgfmathsetmacro{\xb}{1.5*sin(0.5*\angphiy r)*\sinty}
  65.     \pgfmathsetmacro{\yb}{1.5*cos(0.5*\angphiy r)}
  66.     \pgfmathsetmacro{\zb}{1.5*sin(0.5*\angphiy r)*\costy}
  67.     \node[red] at (\xb,\yb,\zb) {\footnotesize$\beta$};
  68.     %
  69.     \pgfmathsetmacro{\xc}{1.5*sin(0.5*\angphiz r)*\costz}
  70.     \pgfmathsetmacro{\yc}{1.5*sin(0.5*\angphiz r)*\sintz}
  71.     \pgfmathsetmacro{\zc}{1.5*cos(0.5*\angphiz r)}
  72.     \node[red] at (\xc,\yc,\zc) {\footnotesize$\gamma$};
  73.     %
  74.   \end{tikzpicture}
  75.   %
  76. \end{document}
复制代码

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-9-16 22:16
@kuing 建议添加 BBcode 支持调用 kroki.io,以便从各种文本描述(包括 tikz、PlantUML、GraphViz 等)生成图表。应该与调用 i.upmath.me 相同,但 kroki.io 支持更多类型。


官方主页有一个实时编辑器,可以选择多种图表类型。
Screenshot 2024-09-16 221813.png

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 12:21

Powered by Discuz!

× 快速回复 返回顶部 返回列表