两辆坦克 - 平局

两辆坦克 - 平局

我是一名 TIKZ 初学者,打算做一些数学笔记,如果有人可以为我绘制(设计/编程)一个像这样的双罐系统,我将不胜感激:

草图

答案1

以下是一些入门知识

截屏

我确信它可以做得更智能,但它确实完成了工作:)

我已经使用了siunitx排版单位——也许这有点过头了,但我认为值得好好做这些事情。如果你加载nicefrac包,然后您就可以使用fraction-function = \nicefrac;根据您认为合适的方式进行实验。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{siunitx}
\sisetup{per-mode=fraction} %,fraction-function = \nicefrac}
\DeclareSIUnit{\gallon}{gal}

% set the arrows as stealth fighters (personal preference)
\tikzset{>=stealth}

\begin{document}

\begin{tikzpicture}
    % draw the tanks
    \draw (0,6)--(0,0)--(3,0)--(3,1)--(4,1)--(4,0)--(6,0)--(6,-1);
    \draw (7,-1)--(7,5)--(4,5)--(4,4)--(3,4)--(3,5)--(1,5)--(1,6);
    % fill them with water (in the background)
    \begin{pgfonlayer}{background}
        \filldraw[blue!20] (0,4.5)--(3,4.5)--(3,4)% tank 1
                                  --(4,4)         % connection
                                  --(4,4.5)--(7,4.5)--(7,-1)--(6,-1)--(6,0)--(4,0) % tank 2
                                  --(4,1)--(3,1)--(3,0)--(0,0) %back to tank 1
                                  -- cycle;
    \end{pgfonlayer}
    % connection piece
    \filldraw[white,draw=black] (3,2)--(3,3)--(4,3)--(4,2)--cycle;
    % add the rates
    \draw[->] (0.5,6)--(0.5,5)node[pos=0,anchor=south west]{\SI{20}{\gallon\per\minute}};
    \draw[->] (6.5,0)--(6.5,-1)node[pos=1,anchor=north]{\SI{20}{\gallon\per\minute}};
    \draw[->] (3,1.5)--(4,1.5)node[anchor=south]{\SI{30}{\gallon\per\minute}};
    \draw[<-] (3,3.5)--(4,3.5)node[anchor=south]{\SI{10}{\gallon\per\minute}};
    \node at (1,1){Tank 1};
    \node at (6,1){Tank 2};
\end{tikzpicture}

\end{document}

答案2

如果您想专心写作,没有太多时间学习 PGF/TikZ,那么 GeoGebra 是另一个选择。下图(及相关代码)是使用 GeoGebra 在大约 10 分钟内生成的。 在此处输入图片描述

以下是 GeoGebra 生成的代码。

\documentclass[9pt]{article}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1.0cm,y=1.0cm]
\clip(-4,-2) rectangle (11,5);
\draw [rotate around={0:(0.5,3)}] (0.5,3) ellipse (1.51cm and 0.19cm);
\draw (-1,3)-- (-1,0);
\draw (2,3)-- (2,0);
\draw [rotate around={0:(0.5,0)}] (0.5,0) ellipse (1.51cm and 0.19cm);
\draw [rotate around={0:(5.5,3)}] (5.5,3) ellipse (1.51cm and 0.19cm);
\draw (4,3)-- (4,0);
\draw (7,3)-- (7,0);
\draw [rotate around={0:(5.5,0)}] (5.5,0) ellipse (1.51cm and 0.19cm);
\draw (-3,4.4)-- (-1,4.4);
\draw (-3,4)-- (-1,4);
\draw [shift={(-1.6,4.2)}] plot[domain=-0.32:0.32,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(-0.4,4.2)}] plot[domain=2.82:3.46,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw (2,2.4)-- (4,2.4);
\draw (2,2)-- (4,2);
\draw [shift={(3.4,2.2)}] plot[domain=-0.32:0.32,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(4.6,2.2)}] plot[domain=2.82:3.46,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw (2,1)-- (4,1);
\draw (2,0.6)-- (4,0.6);
\draw [shift={(3.39,0.8)}] plot[domain=-0.32:0.32,variable=\t]({1*0.64*cos(\t r)+0*0.64*sin(\t r)},{0*0.64*cos(\t r)+1*0.64*sin(\t r)});
\draw [shift={(4.59,0.8)}] plot[domain=2.82:3.47,variable=\t]({1*0.62*cos(\t r)+0*0.62*sin(\t r)},{0*0.62*cos(\t r)+1*0.62*sin(\t r)});
\draw [shift={(1.4,2.2)}] plot[domain=-0.32:0.32,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(2.6,2.2)}] plot[domain=2.82:3.46,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(1.4,0.8)}] plot[domain=-0.32:0.32,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(2.6,0.8)}] plot[domain=2.82:3.46,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw (7,1)-- (7.4,1);
\draw (7,0.6)-- (7.4,0.6);
\draw (7.6,0.4)-- (7.6,-0.2);
\draw (8,0.4)-- (8,-0.2);
\draw [shift={(7.4,0.4)}] plot[domain=0:1.57,variable=\t]({1*0.2*cos(\t r)+0*0.2*sin(\t r)},{0*0.2*cos(\t r)+1*0.2*sin(\t r)});
\draw [shift={(7.4,0.4)}] plot[domain=0:1.57,variable=\t]({1*0.6*cos(\t r)+0*0.6*sin(\t r)},{0*0.6*cos(\t r)+1*0.6*sin(\t r)});
\draw [shift={(7.8,0.4)}] plot[domain=4.39:5.03,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(7.8,-0.8)}] plot[domain=1.25:1.89,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(6.4,0.8)}] plot[domain=-0.32:0.32,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw [shift={(7.6,0.8)}] plot[domain=2.82:3.46,variable=\t]({1*0.63*cos(\t r)+0*0.63*sin(\t r)},{0*0.63*cos(\t r)+1*0.63*sin(\t r)});
\draw (-0.8,4.2)-- (-0.4,4.2);
\draw [->] (-0.2,4) -- (-0.2,3.4);
\draw [shift={(-0.4,4)}] plot[domain=0:1.57,variable=\t]({1*0.2*cos(\t r)+0*0.2*sin(\t r)},{0*0.2*cos(\t r)+1*0.2*sin(\t r)});
\draw [->] (3.4,2.6) -- (2.6,2.6);
\draw [->] (2.6,0.4) -- (3.4,0.4);
\draw [->] (7.8,-0.4) -- (7.8,-1.2);
\draw (-.2,4) node[anchor=north west] {$20 gal/min$};
\draw (2,3.2) node[anchor=north west] {$10 gal/min$};
\draw (2,0.4) node[anchor=north west] {$30 gal/min$};
\draw (8.1,-0.5) node[anchor=north west] {$20 gal/min$};
\draw (0.06,2.29) node[anchor=north west] {$\# 1$};
\draw (5.2,2.26) node[anchor=north west] {$\#2$};
\end{tikzpicture}
\end{document}

相关内容