我找到了一个使用 Tikz 绘制爆炸的好方法(TiKZ:“手绘”大爆发)
但是,我只需要这个形状的上半部分。我该如何裁剪下半部分?
这是我绘图的一些代码,目的是在井底制造爆炸。
\begin{tikzpicture}
%-> DRAW THE EXPLOSION
\node[starburst, draw, minimum width=0.3cm, minimum height=0.4cm, red, fill=orange] at (0,0) {};
%-> DEFINE THE FUNCTIONS OF THE PARABOLAS
\def\v0{7.5}
\def\fcn#1{tan(#1)*abs(\x) - 9.8*(\x)^2/(2*(\v0*cos(#1))^2)}
\def\Fcn{(\v0)^2/19.6 - 9.8*(\x)^2/(2*(\v0)^2)}
\def\xrange#1{(\v0)^2*sin(2*#1)/9.8}
%-> DRAW THE WELL
\def\well#1{
\foreach \x in {#1}
\fill[gray!25,opacity=0.25]
({-#1},{\Fcn}) rectangle({-\xrange{45}},0)
({#1},{\Fcn}) rectangle({\xrange{45}},0)
;
\foreach \x in {#1}
\draw[gray]
({-#1},0)--
({-#1},{\Fcn})--
({-\xrange{45}},{\Fcn})
({#1},0)--
({#1},{\Fcn})--
({\xrange{45}},{\Fcn})
;
}
\def\wellrad{2}
\well{\wellrad}
%-> DRAW THE PARABOLAS
\def\myplot#1#2{
\draw[samples=100,domain=-\xrange{#1}:\xrange{#1},#2]
plot (\x, {\fcn{#1}});
}
\myplot{75}{dotted,gray}
\myplot{60}{dotted,gray}
\myplot{45}{dash dot,gray}
\myplot{30}{dashed,gray}
\myplot{15}{dashed,gray}
\draw[thick,domain=-\xrange{45}:\xrange{45}]
plot (\x, {\Fcn});
%-> DRAW THE AXIS
%... horizontal
\draw[->, very thick]
({-\xrange{45}-0.5},0)--
({\xrange{45}+0.5},0) node[below]{$x$}
;
%... vertical
\draw[->, very thick]
(0,0)--
(0,{\xrange{45}/2+0.5}) node[left]{$y$}
;
%-> DRAW THE NODES
\draw
({-\wellrad},0) node[below]{$-R$}
(0,0) node[below]{0}
({\wellrad},0) node[below]{$R$}
;
\foreach \x in {\wellrad}
\draw[<->, very thick]
({-\xrange{45}-0.2},0)--
({-\xrange{45}-0.2},{\Fcn}) node[midway, left]{$h$}
;
\end{tikzpicture}
答案1
您可以只剪辑星爆。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
%-> DRAW THE EXPLOSION
\begin{scope}
\clip (-2,0) rectangle (2,2);
\node[starburst, draw, minimum width=0.3cm, minimum height=0.4cm, red, fill=orange] at (0,0) {};
\end{scope}
%-> DEFINE THE FUNCTIONS OF THE PARABOLAS
\def\v0{7.5}
\def\fcn#1{tan(#1)*abs(\x) - 9.8*(\x)^2/(2*(\v0*cos(#1))^2)}
\def\Fcn{(\v0)^2/19.6 - 9.8*(\x)^2/(2*(\v0)^2)}
\def\xrange#1{(\v0)^2*sin(2*#1)/9.8}
%-> DRAW THE WELL
\def\well#1{
\foreach \x in {#1}
\fill[gray!25,opacity=0.25]
({-#1},{\Fcn}) rectangle({-\xrange{45}},0)
({#1},{\Fcn}) rectangle({\xrange{45}},0)
;
\foreach \x in {#1}
\draw[gray]
({-#1},0)--
({-#1},{\Fcn})--
({-\xrange{45}},{\Fcn})
({#1},0)--
({#1},{\Fcn})--
({\xrange{45}},{\Fcn})
;
}
\def\wellrad{2}
\well{\wellrad}
%-> DRAW THE PARABOLAS
\def\myplot#1#2{
\draw[samples=100,domain=-\xrange{#1}:\xrange{#1},#2]
plot (\x, {\fcn{#1}});
}
\myplot{75}{dotted,gray}
\myplot{60}{dotted,gray}
\myplot{45}{dash dot,gray}
\myplot{30}{dashed,gray}
\myplot{15}{dashed,gray}
\draw[thick,domain=-\xrange{45}:\xrange{45}]
plot (\x, {\Fcn});
%-> DRAW THE AXIS
%... horizontal
\draw[->, very thick]
({-\xrange{45}-0.5},0)--
({\xrange{45}+0.5},0) node[below]{$x$}
;
%... vertical
\draw[->, very thick]
(0,0)--
(0,{\xrange{45}/2+0.5}) node[left]{$y$}
;
%-> DRAW THE NODES
\draw
({-\wellrad},0) node[below]{$-R$}
(0,0) node[below]{0}
({\wellrad},0) node[below]{$R$}
;
\foreach \x in {\wellrad}
\draw[<->, very thick]
({-\xrange{45}-0.2},0)--
({-\xrange{45}-0.2},{\Fcn}) node[midway, left]{$h$}
;
\end{tikzpicture}
\end{document}