首先我要创建这个图像:
这是我的 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}
我想创建三角曲线,我认为它是 sin2x + cos^2 x 或其他东西......而不仅仅是一条线 y=x 和 y=-x 来创建一个圆锥。
我这个技巧是否足够好,即在中间部分创建两个圆圈?有没有更好的方法,用两个圆圈和中间的白色来创建中间部分?
答案1
以下是我想到的办法。有更好的办法,但看起来不错:
最困难的部分是填充青色管段。
为了回答你的问题,我粘贴了我上面的评论
问题是关于正弦波频率。任何正弦函数都可以定义为:A sin(2 pi ft + phi)。A 是振幅,pi 是 3.14。f 是频率,t 是时间(在绘图的情况下为 x),phi 是原点的相位。您可以通过修改 f 和 phi 来修改正弦(余弦)波:
\draw[-,thick,domain=0:5,samples=100] plot (\x, {sin(25*2*3.14*\x)-(cos(25*2*3.14*\x))^2-\x});
我还添加/替换了 x 以使正弦波上升/下降。
\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}
答案2
另一种方法是使用渐近线。你可以使用http://asymptote.ualberta.ca/和/或使用asymptote
文档 asymptote.pdf 第 7 章:LaTeX 用法中的包。
代码
//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)*"$x$", position=EndPoint),arrow=Arrows3(5mm)); //x-axis
draw((0,0,0)--(0,5,0), green,L=Label(scale(4)*"$y$", position=EndPoint),arrow=Arrows3(5mm)); //y-axis
draw((0,0,0)--(0,0,5), red,L=Label(scale(4)*"$z$", 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)*"$\Delta x_i$",position=MidPoint,align=N),ph1--ph2,2bp+blue);
draw(Label(scale(4)*"$y_i$",position=MidPoint,align=E),p2--pp2,2bp+dashed+red,arrow=Arrows3(5mm));
答案3
我不知道你的曲线方程,所以这是一个近似值,但高度可定制。
我正在画圆。这种方法很容易将切点放置在您想要的任何位置。但由于圆在透视图中被视为椭圆,因此我更改了 xscale。
第一部分是放置所有点。对于每个圆,我们需要中心和切点。然后我们需要极坐标,这样我们就知道切线的角度了。
其余的:一对或弧线和曲线,如
(A1) to[out=\aa-90,in=\ab+90] (B1) ...
上述代码绘制了一条曲线,该曲线以一个角度\aa-90
(与第一个圆相切)离开点(A1),并以一个\ab+90
与第二个圆相切的角度到达点(B1)。
完整示例:
\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}
答案4
这是一个有效的代码:
\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[<->] (2,3.5) -- (2.4,3) node[above, midway] {\footnotesize $\triangle x_{i}$};
\draw[<->] (2,0) -- (2,2.8) node[right, midway] {\footnotesize $y_{1}$};
\draw[->,thick] (-1,0) -- (5,0) node[above] {\footnotesize $x$};
\end{tikzpicture}
\end{document}