3

Is any simple way to draw torus with cross-section and cut like in picture? enter image description here

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}

\begin{document}

\begin{tikzpicture}
\node [draw, cylinder, shape aspect=6, rotate=90, cylinder uses custom fill, cylinder body fill=lightgray!20, minimum height=1cm, minimum width=4cm] at (0,0) {};

\node [draw, cylinder, shape aspect=4, rotate=90, minimum height=1cm, minimum width=3cm] at (0,0.2) {};

\end{tikzpicture}

\end{document}
2

2 Answers 2

4

An adaptation of a previous answer I made.

The output

enter image description here

The code

\documentclass[12pt,tikz,border=2pt]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\def\circDomain[#1]<#2:#3>
{
  \def\angA{#2}
  \def\angB{#3}
  \draw [#1] (\angA:\RR) arc (\angA:\angB:\RR) 
          -- (\angB:\R)  arc (\angB:\angA:\R) 
          -- (\angA:\R) -- cycle;
}
%
\def\rectangleSection[#1]<#2>
{
  \def\angA{#2}
  \draw[#1] (\angA:\RR) -- (\angA:\R) 
    {[topFloor]
           -- (\angA:\R) -- (\angA:\RR)  
    } -- cycle;
}
% 
\def\verticalFaces[#1]<#2:#3:#4>
{
  \def\angA{#2}
  \def\angB{#3}
  \def\r{#4}
  \draw [#1] (\angA:\r) arc (\angA:\angB:\r) 
    {[topFloor] 
          -- (\angB:\r) arc (\angB:\angA:\r) 
    } -- cycle;
}

% viewingAngles %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\angThe{70}                                   %%
\def\angPhi{40}                                   %%
\tdplotsetmaincoords{\angThe}{\angPhi}            %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% shapeParametrization %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\R{1.5}     % radius of the inner plate       %%
\def\RR{2}      % outer radius                    %%
\def\z{.5}      % thickness of the cake           %%
\def\angOp{0}   % first angle of section          %%
\def\angCl{350} % second angle of section         %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\tikzset{topFloor/.style={shift={(vert)}}}
\begin{tikzpicture}[scale=4,tdplot_main_coords]

  \coordinate (vert) at (0,0,\z); % vertical vector

  %\circDomain[fill]<\angOp:\angCl> % this is hidden

  \begin{scope}[fill=red!15]
    \verticalFaces[fill]<\angPhi:\angPhi+180:\R>
  \end{scope}

  \begin{scope}[fill=green!10]
    \rectangleSection[fill]<\angOp>
    \rectangleSection[fill]<\angCl> % hidden
  \end{scope}

  \begin{scope}[fill=red!15]
    \verticalFaces[fill]<\angOp:\angPhi:\RR>
    \verticalFaces[fill]<\angCl:\angPhi+180:\RR>
  \end{scope}

  \begin{scope}[shift={(vert)},fill=blue!20]
    \circDomain[fill]<\angOp:\angCl>
  \end{scope}

\end{tikzpicture}
\end{document}
4
  • Thank you. Excellent!!! It is possible to wire wrapping around? Jul 15, 2017 at 12:54
  • @sergiokapone Cheers ! Sorry but I don't know what you mean by wire wrapping around
    – marsupilam
    Jul 15, 2017 at 13:06
  • Sorry for my English, I mean something like this cdn.miniphysics.com/wp-content/uploads/2015/08/… Jul 15, 2017 at 13:09
  • Oh you mean this the magnetic core of an electromagnetic coil, and you wish to have a wire wrapped around it ? This seems honestly hard to do in tikZ...
    – marsupilam
    Jul 15, 2017 at 13:10
5

A very quick sketch

\documentclass[tikz]{standalone}
\tikzset{invclip/.style={clip,
  insert path={{[reset cm](-\maxdimen,-\maxdimen) rectangle (\maxdimen,\maxdimen)}}}}
\begin{document}
\begin{tikzpicture}
\path (0,0) ellipse (1 and 0.5);% Just to make the bounding box big enough
\begin{scope}
\path[overlay,invclip] (0,0) --+(-30:1) --+(-20:1)--cycle;
\draw (0,0) ellipse (1.2 and 0.4) ellipse (0.9 and 0.25);
\end{scope}
\draw (-1.2,0) --++(0,-0.3) arc (180:300:1.2 and 0.4) --++(0,0.3) coordinate (c1) --++(150:0.24)coordinate (c2);
\draw (1.2,0) --++(0,-0.3) arc (0:-48:1.2 and 0.4) coordinate (b1) --++(0,0.3) coordinate (b2) --++(160:0.28)coordinate (b3);
\end{tikzpicture}
\end{document}

Lots of eyeballing but can be made precise with points on ellipse formulas or intersecting the clip path with the ellipses separately. To be honest, I was bored already :)

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .