0

I'm trying to draw the following diagram in TikZ : enter image description here

Here's my attempt to draw it :

\documentclass[tikz,border=50mm]{standalone}
\usetikzlibrary{calc}
\usepackage{tikz-3dplot}
\usetikzlibrary{3d}
\usetikzlibrary{arrows.meta}
\usepackage{circuitikz}
\usetikzlibrary{decorations.pathmorphing,patterns, snakes}
\usetikzlibrary{arrows, shapes, positioning, calc, decorations.text, angles, 
               quotes}
\usetikzlibrary{decorations.markings}
\begin{tikzpicture}[scale=2 ,>=stealth]
    \foreach \i in {0,2} {
    \draw[black, thick] (2,\i) arc [x radius=2, y radius=0.5, start angle=0, end angle=180];
    \draw[black,  thick] (-2,\i) arc [x radius=2, y radius=0.5, start angle=180, end angle=360];
        }
    \draw[->] (2,0) arc [start angle=0,end angle=2,x radius=2cm,y radius =1cm] ;
    \node[right] at (2.1,0) {$I$};
    \draw[<-] (2,2) arc [start angle=2,end angle=4,x radius=2cm,y radius =1cm] ;
    \node[right] at (2.1,2) {$I$};
    \draw[->] (0,0)--(-2,0) node[midway, above] {$R$};
    \draw[->] (0,2)--(-2,2) node[midway, above] {$R$};
    \draw[smooth, dashed, ->] (0,-2)--(0,4) node[left] {$z$};
    \filldraw[] (0,0)circle(0.025) node[right] {$O_1$};
    \filldraw[] (0,2)circle(0.025) node[right] {$O_2$};
    \filldraw[] (0,1)circle(0.025) node[left] {$M$};
    \filldraw[] (0,3.5)circle(0.025) node[left] {$N$};
    \filldraw[] (0,-1.5)circle(0.025) node[left] {$P$};
    \draw[smooth, <->] (0.5, 2)--(0.5,3.5) node[right, midway] {$a$};
    \draw[smooth, <->] (0.5, 2)--(0.5, 1) node[right, midway] {$d/2$};
    \draw[smooth, <->] (0.5, 1)--(0.5,0) node[right, midway] {$d/2$};
    \draw[smooth, <->] (0.5, 0)--(0.5,-1.5) node[right, midway] {$b$};
    \end{tikzpicture}

Here's the result (that's not satisfying me) I just want to know how can I draw an ellipse with an arrow as the figure shows, and how can I make it look more fancy ?

enter image description here

6
  • Not much. You could fill the ellipses (see opacity) and cover the line segments below (drawing everything in sections from the bottom up). Jan 12, 2022 at 18:12
  • @JohnKormylo I forgot to mention that the radius looks terrible too
    – euler_med
    Jan 12, 2022 at 18:19
  • 1
    Note that you are only using TikZ, not tikz-3dplot. You would have to specify the viewing angle using \tdplotsetmaincoords. Circles are drawn in the x,y plane. Jan 12, 2022 at 18:56
  • Problem solved? :) Feb 13, 2022 at 1:43
  • @Dr.ManuelKuehner I don't think so :/
    – euler_med
    Feb 13, 2022 at 12:55

1 Answer 1

1

This makes the circles slightly opaque.

\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}[scale=2 ,>=stealth]
    \draw[dashed] (0,-2)--(0,0);% bottom
    \filldraw[] (0,-1.5)circle(0.025) node[left] {$P$};
    \draw[<->] (0.5, 0)--(0.5,-1.5) node[right, midway] {$b$};
    
    \fill[white, opacity=0.5] (0,0) circle[x radius=2cm,y radius =0.5cm];
    \draw[black, thick] (0,0) circle[x radius=2cm,y radius =0.5cm];
    \draw[->] (2,0) arc [start angle=0,end angle=2,x radius=2cm,y radius =1cm] ;
    \node[right] at (2.1,0) {$I$};
    
    \draw[dashed] (0,0)--(0,2);% middle
    \draw[->] (0,0)--(-2,0) node[midway, above] {$R$};
    \filldraw[] (0,0)circle(0.025) node[right] {$O_1$};
    \draw[<->] (0.5, 1)--(0.5,0) node[right, midway] {$d/2$};
    \draw[<->] (0.5, 2)--(0.5, 1) node[right, midway] {$d/2$};
    \filldraw[] (0,1)circle(0.025) node[left] {$M$};
    
    \fill[white, opacity=0.5] (0,2) circle[x radius=2cm,y radius =0.5cm];
    \draw[black, thick] (0,2) circle[x radius=2cm,y radius =0.5cm];
    \draw[<-] (2,2) arc [start angle=2,end angle=4,x radius=2cm,y radius =1cm] ;
    \node[right] at (2.1,2) {$I$};
    
    \draw[->] (0,2)--(-2,2) node[midway, above] {$R$};
    \draw[dashed, ->] (0,2)--(0,4) node[left] {$z$};% top
    \filldraw[] (0,2)circle(0.025) node[right] {$O_2$};
    \filldraw[] (0,3.5)circle(0.025) node[left] {$N$};
    \draw[<->] (0.5, 2)--(0.5,3.5) node[right, midway] {$a$};

    \end{tikzpicture}

\end{document}

This version uses tikz-3dplot. If you specify the radius in units (cm), circles will be drawn using screen coordinates instead of the x,y plane.

\documentclass{standalone}
\usepackage{tikz}% do not use the tikz option of standalone
\usetikzlibrary{arrows.meta}
\usepackage{tikz-3dplot}

\begin{document}
\tdplotsetmaincoords{75}{0}
\begin{tikzpicture}[tdplot_main_coords, scale=2 ,>=stealth]
    \draw[dashed] (0,0,-2)--(0,0,0);% bottom
    \filldraw[] (0,0,-1.5) circle(0.025cm) node[left] {$P$};
    \draw[<->] (0.5,0, 0)--(0.5,0,-1.5) node[right, midway] {$b$};
    
    \fill[white, opacity=0.5] (0,0,0) circle[radius=2];
    \draw[black, thick] (0,0,0) circle[radius=2];
    \draw[thick, ->] (2,0,0) --(2,0.2,0);
    \node[right] at (2.1,0,0) {$I$};
    
    \draw[dashed] (0,0,0)--(0,0,2);% middle
    \draw[->] (0,0,0)--(-2,0,0) node[midway, above] {$R$};
    \filldraw[] (0,0,0) circle(0.025cm) node[right] {$O_1$};
    \draw[<->] (0.5,0, 1)--(0.5,0,0) node[right, midway] {$d/2$};
    \draw[<->] (0.5,0, 2)--(0.5,0, 1) node[right, midway] {$d/2$};
    \filldraw[] (0,0,1) circle(0.025cm) node[left] {$M$};
    
    \fill[white, opacity=0.5] (0,0,2) circle[radius=2];
    \draw[black, thick] (0,0,2) circle[radius=2];
    \draw[thick, ->] (2,0,2) -- (2,-0.2,2);
    \node[right] at (2.1,0,2) {$I$};
    
    \draw[->] (0,0,2)--(-2,0,2) node[midway, above] {$R$};% top
    \draw[dashed, ->] (0,0,2)--(0,0,4) node[left] {$z$};% top
    \filldraw[] (0,0,2) circle(0.025cm) node[right] {$O_2$};
    \filldraw[] (0,0,3.5) circle(0.025cm) node[left] {$N$};
    \draw[<->] (0.5,0, 2)--(0.5,0,3.5) node[right, midway] {$a$};
    \end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.