我有以下代码,描述了一个带有转子和发电机的系统
代码如下
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
bending,
calc, chains,
decorations.pathmorphing, % added
positioning
}
\usepackage{tikz-3dplot}
\begin{document}
\begin{figure}
%% viewing angles %%
\def\angThe{70} %%
\def\angPhi{50} %%
%%%%%%%%%%%%%%%%%%%%
\tdplotsetmaincoords{\angThe}{\angPhi}
\tikzset
{
rotor/.pic={
\begin{scope}[tdplot_main_coords,rotate=90,line width=.2pt]
\def\r{3.1}
\def\z{2}
%\draw [very thick,blue] (0,0,-\z-2) -- (0,0) ;
\pgfmathsetmacro{\angPhiOpp}{\angPhi-180}
\draw [fill=gray!20] (\angPhi:\r) arc (\angPhi:\angPhiOpp:\r)
{[shift={(0,0,-\z)}]
-- (\angPhiOpp:\r) arc (\angPhiOpp:\angPhi:\r)
} -- cycle;
\begin{scope}
\draw [clip] (0,0) circle (\r) ;
\fill [gray!20] (0,0) circle (\r) ;
\draw [fill=gray!60,even odd rule] (0:\r) circle (\r)
(120:\r) circle (\r)
(240:\r) circle (\r)
(0,0) circle (2*\r);
\end{scope}
%\draw [very thick,blue] (0,0,2) -- (0,0) ;
\end{scope}
}
}
\begin{tikzpicture}[
node distance = 0mm,
start chain = going right,
box/.style = {draw,fill=blue!20!white, line width=1mm,rounded corners, font=\linespread{0.75},align=center, inner sep=10mm, outer sep=0pt, on chain},
axs/.style = {draw, minimum width=10mm, minimum height=0.1mm,
inner sep=0pt, outer sep=0pt,
on chain, node contents={}},
arr/.style = {color=#1, line width=0.8mm,
shorten >=-1mm, shorten <=-1mm,
-{Stealth[length=1.6mm,width=3mm,flex=1.2]},
bend angle=60},
spring/.style = {thick, decorate, % new,
decoration={zigzag,pre length=3mm,post length=3mm,segment length=6}
},
ellipse/.style = {draw,minimum size=100pt,align=center,on chain},
damper/.pic = {\coordinate (-east); % new
\coordinate[left=1mm of -east] (-west);
\draw[very thick] ($(-east)+(0,2mm)$) -- ++ (0,-4mm);
\draw[thick] ($(-east)+(0,3mm)$) -| ++ (-1mm,-6mm) -- ++ (1mm,0);
},
shorten <>/.style = {shorten >=#1, shorten <=#1},
]
% blocks (boxes)
\node (n1) [label=below:$J_M$] {};
\pic (rotor) at (n1.south) {rotor};
%\node (n1) [box,label=below:$J_M$] {Rotor};
%\node (n1) [ellipse,label=below:$J_M$] {Rotor};
\node (n2) [axs];
%\node (n3) [box] {$\tau$};
%\node (n4) [axs];
\node (n2) [minimum height=6mm,minimum width=12mm,
label={[yshift= 1mm]above:$K$},
label={[yshift=-3mm]below:$D$},
on chain] {};% for spring and dumper
\node (n3) [axs];
\node (n4) [box,label=below:$J_G$,fill=blue!20!white,rounded corners] {Generator};
% spring and damper, added
\draw[ultra thick,shorten <>=-2mm]
(n2.north west) -- (n2.south west);
\draw[ultra thick,shorten <>=-2mm]
(n2.north east) -- (n2.south east);
\draw[spring] (n2.north west) -- (n2.north east);
\pic (dmp) at (n2.south) {damper};
\draw(n2.south west) -- (dmp-west) (dmp-east) -- (n2.south east);
\end{tikzpicture}
\end{figure}
\end{document}
问题是我想绘制两个圆形框和一个椭圆形,如下图所示。请注意,图中的叶片可以省略。
谢谢
答案1
由于您没有提供完整的 MWE,因此您的代码无法编译。
看看以下内容是否有帮助:
输出
代码
\documentclass[12pt,tikz]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
%% viewing angles %%
\def\angThe{70} %%
\def\angPhi{50} %%
%%%%%%%%%%%%%%%%%%%%
\tdplotsetmaincoords{\angThe}{\angPhi}
\tikzset
{
rotor/.pic={
\begin{scope}[tdplot_main_coords,rotate=90,line width=.2pt]
\def\r{3.1}
\def\z{2}
\draw [very thick,blue] (0,0,-\z-2) -- (0,0) ;
\pgfmathsetmacro{\angPhiOpp}{\angPhi-180}
\draw [fill=pink] (\angPhi:\r) arc (\angPhi:\angPhiOpp:\r)
{[shift={(0,0,-\z)}]
-- (\angPhiOpp:\r) arc (\angPhiOpp:\angPhi:\r)
} -- cycle;
\begin{scope}
\draw [clip] (0,0) circle (\r) ;
\fill [gray!20] (0,0) circle (\r) ;
\draw [fill=blue!20,even odd rule] (0:\r) circle (\r)
(120:\r) circle (\r)
(240:\r) circle (\r)
(0,0) circle (2*\r);
\end{scope}
\draw [very thick,blue] (0,0,2) -- (0,0) ;
\end{scope}
}
}
\begin{tikzpicture}
\pic at (0,0) {rotor};
\end{tikzpicture}
\end{document}