1

first of all I want to create this image:

1

Here is my MWE:

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=1,>=latex,x=1.5cm,y=0.8cm]
        \fill[fill=white,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{sqrt(2*(\x)+1))}) -- (4,0);
        \fill[fill=white,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{-sqrt(2*(\x)+1))}) -- (4,0);
        \draw[-,thick,domain=-.2:4.5,samples=100] plot (\x,\x) node[right] {\footnotesize $$};
        \draw[-,thick,domain=-.2:4.5,samples=100] plot (\x,-\x);
    % Circle
    \draw[fill=white!40] (0.5,0) circle [x radius =.3 , y radius =0.5];
    \draw[fill=blue!40] (3.3,0) circle [x radius =.3 , y radius =3.249489743];
    \draw[fill=white!20] (3.3,0) circle [x radius =.13 , y radius =3.249489743];
    \draw[fill=blue!40] (4.5,0) circle [x radius =.3 , y radius =4.449489743];

    \draw[<->] (3.3,3.7) -- (4.5,4.9) node[above, midway]  {\footnotesize $l$};
    \draw[<->] (3.7,0) -- (3.7,3.249489743) node[right, midway]  {\footnotesize $y_{1}$};
    \draw[->,thick] (-1,0) -- (5,0) node[above] {\footnotesize $x$};
    \draw[->,thick] (0,-5) -- (0,5) node[below right]{\footnotesize $y$};
\end{tikzpicture}

\end{document}

2

  1. I want to create the trigonometric curves, I think it is sin2x + cos^2 x or something.. Instead of just a line y=x and y=-x that will create a cone.

  2. Is my trick to create two circles for the middle part good enough? Is there a better method to create the middle part with two circle and white in the middle?

  • Hello, concerning 1. you can plot any function with the correct domain and formula as a path: \draw[-,thick,domain=-55:50,samples=100] plot (\x,{sin(2*\x)+(cos(\x))^2}); but the function you gave isn't the one you need https://www.desmos.com/calculator/0i2onunbmz. check the doc for tizk plot https://tikz.dev/tikz-plots – anis Jan 11 '23 at 13:14
  • You can also approximate the plot via Bézier's curves https://tikz.dev/tikz-paths#sec-14.3 – anis Jan 11 '23 at 13:15
  • I add this line: \draw[-,thick,domain=0:5,samples=10] plot (\x,{sin(2*\x)}); or your suggestion, it is only a straight line. Is it the canvas size problem? – Freya the Goddess Jan 11 '23 at 13:31
  • I try to plot x + 2 cos x with Julia it shows a curve that I want, but with tikz this line \draw[-,thick,domain=0:10,samples=10] plot (\x,{(\x) + 2*(cos(\x)) }); gives straight line... what is wrong with this? – Freya the Goddess Jan 11 '23 at 13:38
  • 1
    the question is about sin waves frequency. any sin func can be defined by : A sin (2 pi f t+ phi). A is the amplitude, pi is 3.14.. f is the frequency, t is time (x in the case of a plot) and phi is the phase at the origin. – anis Jan 11 '23 at 13:40
  • you can modify you sin (cos) waves by modifying f and phi. \draw[-,thick,domain=0:5,samples=100] plot (\x,{sin(25*2*3.14*\x)-(cos(25*2*3.14*\x))^2-\x}); i also added/subbed x to have the sin wave rise/lower. – anis Jan 11 '23 at 13:42
  • Done, I have added an answer – Freya the Goddess Jan 11 '23 at 14:41
  • nice, I amma keep guiding you to find the final form. Remember the last complex diagram you posted here and I answered? can you reuse anything from that? – anis Jan 11 '23 at 14:44
  • Which last complex diagram? The one I answer below? like Church Bell.. – Freya the Goddess Jan 13 '23 at 12:34
  • 1
    This one, @Freya, https://tex.stackexchange.com/questions/670107/how-to-create-annotations-with-curly-brackets-in-tikz – anis Jan 13 '23 at 12:35

4 Answers4

2

Here is what I came up with. There are better ways to do it but it looks fine:

The hardest part is to fill the cyan tube segment.

To answer your question, I am pasting my comment from above

The question is about sin waves frequency. Any sin func can be defined by: A sin (2 pi f t + phi). A is the amplitude, pi is 3.14.. f is the frequency, t is time (x in the case of a plot) and phi is the phase at the origin. You can modify you sin (cos) waves by modifying f and phi:

\draw[-,thick,domain=0:5,samples=100] 
plot (\x, {sin(25*2*3.14*\x)-(cos(25*2*3.14*\x))^2-\x});

I also added/subbed x to have the sin wave rise/lower.

enter image description here

\documentclass[12pt]{article}
\usepackage{tikz}

\usetikzlibrary{intersections} \usetikzlibrary{calc}

\begin{document} \begin{tikzpicture}[scale=1,>=latex,x=1.5cm,y=0.8cm] \fill[fill=white,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{sqrt(2(\x)+1))}) -- (4,0); \fill[fill=white,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{-sqrt(2(\x)+1))}) -- (4,0);

\draw[name path = A ,-,thick,domain=0:4.501,samples=100] plot (\x,{sin(25*1*3.14*\x)+(cos(5*1*3.14*\x))^2+\x});
\draw[name path = B, -,thick,domain=0:4.501,samples=100] plot (\x,{-sin(25*1*3.14*\x)-(cos(5*1*3.14*\x))^2-\x});


% \draw[dashed] (0.1,-1.1) arc (-90:90:0.17 and 1.1);% half circle facing left % \draw(0.1,-1.1) arc (-90:90:-0.17 and 1.1);%

% circle left \path[name path = up1] (0,0) -- (0,5); \path[name intersections= {of = {up1 and A}, by =p1}]; \draw let \p1=(p1) in (0,0) circle [y radius=\y1, x radius =\y1/6] ;

%% circle mid % \coordinate (y0) at (2,0); % \path[name path = up2] (y0) -- (2,11); % \path[name intersections= {of = {up2 and A}, by =p2}]; %% \draw let \p1=(p2) in (y0) circle [y radius=\y1, x radius =\y1/6] ; % %
% circle before \coordinate (y1) at (1.9,0);
\path[name path = up3] (y1) -- (1.9,11); \path[name path = down3] (y1) -- (1.9,-11); \path[name intersections= {of = {up3 and A}, by =p3}]; \path[name intersections= {of = {down3 and B}, by =p3s}]; \draw let \p1=(p3) in (y1) circle [y radius=\y1, x radius =\y1/6] ;

% circle after \coordinate (y2) at (2.1,0);
\path[name path = up4] (y2) -- (2.1,11); \path[name path = down4] (y2) -- (2.1,-11); \path[name intersections= {of = {up4 and A}, by =p4}]; \path[name intersections= {of = {down4 and B}, by =p4s}];

% fill mid cone: \fill[cyan,opacity=0.3] let \p1=(p3) in (p3) --(p4) -- (p4s) -- (p3s) arc (-90:-270:\y1/6 and \y1) -- cycle ; \draw [fill=white]let \p1=(p4) in (y2) circle [y radius=\y1, x radius =\y1/6] ; % \draw[<->] (y2) -- (p4) node[right, midway] {\footnotesize $y_{1}$};

% circle
\coordinate (y3) at (4.5,0);
\path[name path = up5] (y3) -- (4.5, 7); \path[name intersections= {of = {up5 and A}, by =p5}]; \draw let \p1=(p5) in (y3) circle [y radius=\y1, x radius =\y1/6] ;

%%%%%%%%%%%%%%% Axis and Delta x \draw[<->] ($(p3)+(0,0.25)$) -- ($(p4)+(0,0.25)$) node [above] {\footnotesize $\triangle x_{i}$}; \draw[->,thick] (-1,0) -- (5,0) node[above] {\footnotesize $x$}; \end{tikzpicture} \end{document}

anis
  • 1,510
  • 5
  • 13
2

An alternative with asymptote. You can test with http://asymptote.ualberta.ca/ and/or use the asymptote package In the doc asymptote.pdf Chapter 7: LaTeX usage.

enter image description here

THE CODE

    //http://asymptote.ualberta.ca/
    //
    //Basic settings
    settings.prc=false;
    settings.render = 8;
import solids;
currentprojection = perspective(3,2,6,up=Y);
unitsize(4cm);// it will be necessary to enlarge to scale 4 the text

// the axes
draw((0,0,0)--(11,0,0), blue,L=Label(scale(4)*&quot;$x$&quot;, position=EndPoint),arrow=Arrows3(5mm)); //x-axis
draw((0,0,0)--(0,5,0), green,L=Label(scale(4)*&quot;$y$&quot;, position=EndPoint),arrow=Arrows3(5mm)); //y-axis
draw((0,0,0)--(0,0,5), red,L=Label(scale(4)*&quot;$z$&quot;, position=EndPoint),arrow=Arrows3); //z-axis
////////////////////////////////////////////////////
triple pO=(0,0,0);
path3 gene=
(0,1,0)..(4.5,3,0)
..(5.5,2.5,0)
..(8,4,0)
..(10,4.5,0);
//   We place two points on the generatrix
triple p1=point(gene, 1);
triple p2=point(gene, 1.1);
// We define a projection on the x axis
transform3 pr=planeproject(Y,O);
triple pp1=pr*p1;
triple pp2=pr*p2;


// We define and draw the surfaces of revolution
revolution sur=revolution(pO,gene,X,0,360);
draw(surface(sur),surfacepen=material(yellow+opacity(0.5)));
//
path3 ray=(0,0,0)--(0,1,0);
revolution disque=revolution(pO,ray,X,0,360);
draw(surface(disque),yellow+opacity(0.5));
//
path3 delta=(p1)--(p2);
revolution surdelta=revolution(pO,delta,X,0,360);
draw(surface(surdelta),surfacepen=material(blue));

//We define two points to display the label delta xi
triple ph1=pp1+(0,3.5,0);
triple ph2=pp2+(0,3.5,0);
//
draw (p1--ph1,bp+dashed);
draw (p2--ph2,bp+dashed);
// The text is enlarged to scale 4
draw (Label(scale(4)*&quot;$\Delta x_i$&quot;,position=MidPoint,align=N),ph1--ph2,2bp+blue);
draw(Label(scale(4)*&quot;$y_i$&quot;,position=MidPoint,align=E),p2--pp2,2bp+dashed+red,arrow=Arrows3(5mm));

pascal974
  • 4,652
2

I don't know the equation of your curve so this is an approximation, but highly customizable.

I am drawing circles. This way is easy to place the points of tangency wherever you want. But as the circles are viewed as ellipses with the perspective, I change the xscale.

The first part is to place all the points. For each circle we need the center, and points of tangency. And we need then in polar coordinates, so we'll know the angels for the tangency.

The rest: a couple or arcs and curves like

(A1) to[out=\aa-90,in=\ab+90] (B1) ...

The above code draws a curve that leaves the point (A1) with an angle \aa-90 (tangent to the first circle) and arrives at (B1) with an angle \ab+90 tangent to the second circle.

The full example:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc}

\begin{document} \begin{tikzpicture}[line cap=round,line join=round,xscale=0.5] % DIMENSIONS AND COORDINATES % first circle from the left \def\xa{0} % position \def\ra{1} % radius \def\aa{95} % angle \coordinate (A0) at (\xa,0); % center \coordinate (A1) at ($(A0)+( \aa:\ra)$); % tangent point above \coordinate (A2) at ($(A0)+(-\aa:\ra)$); % tangent point below % second circle \def\xb{6} % position \def\rb{2} % radius \def\ab{80} % angle \coordinate (B0) at (\xb,0); % center \coordinate (B1) at ($(B0)+( \ab:\rb)$); % tangent point above \coordinate (B2) at ($(B0)+(-\ab:\rb)$); % tangent point below % third circle \def\xc{6.5} % position \def\rc{1.9} % radius \def\ac{80} % angle \coordinate (C0) at (\xc,0); % center \coordinate (C1) at ($(C0)+( \ac:\rc)$); % tangent point above \coordinate (C2) at ($(C0)+(-\ac:\rc)$); % tangent point below % fourth circle \def\xd{13} % position \def\rd{2.9} % radius \def\ad{80} % angle \coordinate (D0) at (\xd,0); % center \coordinate (D1) at ($(D0)+( \ad:\rd)$); % tangent point above \coordinate (D2) at ($(D0)+(-\ad:\rd)$); % tangent point below % DRAWING % section \fill[cyan!10] (B1) to[out=\ab-90,in=\ac+90] (C1) arc (\ac:-\ac:\rc) to[out=270-\ac,in=90-\ab] (B2) arc (-\ab:\ab:\rb); \fill[cyan!60] (C1) to[out=\ab-90,in=\ac+90] (B1) arc (\ab:360-\ab:\rb) to[out=270-\ab,in=90-\ac] (C2) arc (360-\ac:\ac:\rc); % first circle \draw (A1) arc (\aa:360-\aa:\ra); \draw[dashed] (A1) arc (\aa:-\aa:\ra); % rest of the circles \foreach\i/\j in {B/\rb,C/\rc,D/\rd} \draw (\i0) circle (\j); % surface \draw[thick,cyan] (A1) to[out=\aa-90,in=\ab+90] (B1) to[out=\ab-90,in=\ac+90] (C1) to[out=\ac-90,in=\ad+90] (D1); \draw[yscale=-1] (A2) to[out=\aa-90,in=\ab+90] (B2) to[out=\ab-90,in=\ac+90] (C2) to[out=\ac-90,in=\ad+90] (D2); % axis \draw[thick] (-\ra,0) --++ (-1,0); \draw[dashed] (-\ra,0) -- (D0); \draw[thick] (D0) -- (\xd+\rd+1,0); \foreach\i in {A,B,C,D} \fill (\i0) ellipse (0.8mm and 0.4mm); % labels \draw[latex-latex] (C0) --++ (0,\rc) node[midway,right] {$y_1$}; \draw (B0) ++ (0,\rb+0.1) --++ (0,1); \draw (C0) ++ (0,\rc+0.1) --++ (0,1+\rb-\rc); \draw[-latex] (B0) ++ (-0.5,\rb+1) --++ (0.5,0); \draw[-latex] (C0) ++ (0.5,\rb+1) --++ (-0.5,0); \draw (B0) ++ (0,\rb+1) --++ (\xc-\xb,0) node[midway,yshift=3mm] {$\Delta x$}; \end{tikzpicture} \end{document}

enter image description here

Juan Castaño
  • 28,426
1

Here is a working code:

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}[scale=1,>=latex,x=1.5cm,y=0.8cm]
        \fill[fill=white,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{sqrt(2*(\x)+1))}) -- (4,0);
        \fill[fill=white,opacity=0.5] (1,0) -- plot[domain=1:4] (\x,{-sqrt(2*(\x)+1))}) -- (4,0);
    \draw[-,thick,domain=0:4.5,samples=100] plot (\x,{sin(25*1*3.14*\x)+(cos(5*1*3.14*\x))^2+\x});
    \draw[-,thick,domain=0:4.5,samples=100] plot (\x,{-sin(25*1*3.14*\x)-(cos(5*1*3.14*\x))^2-\x});

    % Circle
    \draw[dashed] (0.1,-1.1) arc (-90:90:0.17 and 1.1);% half circle facing left
    \draw(0.1,-1.1) arc (-90:90:-0.17 and 1.1);% 

    \draw[fill=blue!40] (2,0) circle [x radius =.7 , y radius =3.2];
    \draw[fill=white!20] (2,0) circle [x radius =.33 , y radius =3.2];
    \draw[fill=blue!40] (4.5,0) circle [x radius =.3 , y radius =4.449489743];


    \draw[&lt;-&gt;] (2,3.5) -- (2.4,3) node[above, midway]  {\footnotesize $\triangle x_{i}$};
    \draw[&lt;-&gt;] (2,0) -- (2,2.8) node[right, midway]  {\footnotesize $y_{1}$};
    \draw[-&gt;,thick] (-1,0) -- (5,0) node[above] {\footnotesize $x$};
\end{tikzpicture}

\end{document}

1