我正在尝试使用 tikz在圆锥体 ( sqrt(x^2+y^2)
) 下方、圆柱体 ( )内绘制区域。x^2+y^2 = 2x
我的问题是区域定义不明确。我的代码产生了以下奇怪的形状:
看法:{130}{30}
看法:{30}{30}
我正在尝试获得类似这样的信息:
\documentclass[10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[bullet/.style={circle,fill,inner sep=0.5pt}, declare function={f(\x,\y)=(\x^2+\y^2)^0.5;}]
\begin{axis}[view={30}{30},colormap/blackwhite,axis lines=middle,%
zmax=2.5,zmin=0,xmin=-2.5,xmax=3.5,ymin=-2.5,ymax=2.5,%
xlabel=$x$,ylabel=$y$,zlabel=$z$,
xtick=\empty,ytick=\empty,ztick=\empty]
\addplot3[surf,shader=interp,domain=0:2,domain y=-2:2,opacity=0.4] {f(x,y)};
%\draw [fill=white!50!blue, opacity=0.3, smooth, samples=100, domain=0:2] plot(\x, {sqrt(2*\x-\x*\x)}) -- plot[domain=2:0] (\x,{-sqrt(2*\x-\x*\x)}) -- cycle;
\draw [blue, domain=0:2, smooth, variable=\x] plot (\x, {sqrt(2*\x-\x*\x)});
\draw [blue, domain=0:2, smooth, variable=\x] plot (\x, {-sqrt(2*\x-\x*\x)});
\draw [fill=white!50!blue, opacity=0.3, smooth, samples=100, domain=0:2] plot(\x, {sqrt(2*\x-\x*\x)},0) -- plot[domain=2:0] (\x,{sqrt(2*\x-\x*\x)},{f(\x,{sqrt(2*\x-\x*\x)})}) -- cycle;
\draw [red] (1,2) node[]{$D$};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=(\x^2+\y^2)^0.5;}]
\begin{axis}[
view={30}{30},
colormap/blackwhite,
axis lines=middle,
xmin=-2.5, xmax=3.5,
ymin=-2.5, ymax=2.5,
zmax=2.5, zmin=0,
xtick=\empty, ytick=\empty, ztick=\empty,
]
\addplot3[surf,shader=interp,domain=0:2,domain y=-2:2,opacity=0.4] {f(x,y)};
\draw[blue] (1,0,0) circle[radius=1];
\draw[red] plot[domain=0:360, variable=\ang, smooth] ( {cos(\ang)+1} , {sin(\ang)} , {f({cos(\ang)+1},{sin(\ang)})} );
\draw[cyan] ( {cos(210)+1} , {sin(210)} , 0 ) -- ( {cos(210)+1} , {sin(210)} , {f({cos(210)+1},{sin(210)})} );
\draw[cyan] ( {cos(30)+1} , {sin(30)} , 0 ) -- ( {cos(30)+1} , {sin(30)} , {f({cos(30)+1},{sin(30)})} );
\end{axis}
\end{tikzpicture}
\end{document}
\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}[declare function={f(\x,\y)=(\x^2+\y^2)^0.5;}]
\begin{axis}[
view={30}{30},
colormap/blackwhite,
axis lines=middle,
xmin=-2.5, xmax=3.5,
ymin=-2.5, ymax=2.5,
zmax=2.5, zmin=0,
xtick=\empty, ytick=\empty, ztick=\empty,
]
\addplot3[surf,shader=interp,domain=0:2,domain y=-2:2,opacity=0.4] {f(x,y)};
\draw[blue] plot[domain=0:360, variable=\ang, smooth] ( {cos(\ang)+1} , {sin(\ang)} , {f({cos(\ang)+1},{sin(\ang)})} );
\draw[blue] (1,0,0) circle[radius=1];
\fill[white!50!blue, opacity=0.3, smooth, samples=100]
( {cos(210)+1} , {sin(210)} , 0 ) -- ( {cos(210)+1} , {sin(210)} , {f({cos(210)+1},{sin(210)})} ) --
plot[domain=210:390, variable=\ang, smooth] ( {cos(\ang)+1} , {sin(\ang)} , {f({cos(\ang)+1},{sin(\ang)})} ) --
( {cos(30)+1} , {sin(30)} , 0 ) -- ( {cos(30)+1} , {sin(30)} , {f({cos(30)+1},{sin(30)})} ) --
plot[domain=390:210, variable=\ang, smooth] ( {cos(\ang)+1} , {sin(\ang)} , 0 );
\end{axis}
\end{tikzpicture}
\end{document}
答案2
纯钛钾Z 解决方案可能是这样的:
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{3d,calc,perspective}
\tikzset
{
axis/.style={thick,-latex},
cone back/.style={draw=brown,left color=gray!50,right color=brown},
cone front/.style={draw=brown,left color=brown},
cylinder front/.style={draw=blue,left color=blue!50,fill opacity=0.5},
cylinder back/.style={draw=blue,left color=gray!50,right color=blue!50,fill opacity=0.5},
}
\begin{document}
\begin{tikzpicture}[isometric view,rotate around z=180,line cap=round,line join=round]
% coordinates
\coordinate (O) at (0,0,0);
\coordinate (L1) at ($(1,0,0)+(315:1)$);
\coordinate (L2) at ($(L1)+(0,0,{sqrt(2+sqrt(2))})$);
\coordinate (L3) at ($(L1)+(0,0,3)$);
\coordinate (L4) at (3,0,3);
\coordinate (R1) at ($(1,0,0)+(135:1)$);
\coordinate (R2) at ($(R1)+(0,0,{sqrt(2-sqrt(2))})$);
\coordinate (R3) at ($(R1)+(0,0,3)$);
\coordinate (R4) at (0,3,3);
\coordinate (A) at (2,0,2);
\coordinate (B) at (intersection of L1--L3 and O--L4);
% axes
\draw[axis] (O) -- (4,0,0) node [left] {\strut$x$};
\draw[axis] (O) -- (0,4,0) node [right] {\strut$y$};
% cone, back
\draw[cone back] (O) -- (R4) arc (90:360:3) -- cycle;
\draw[blue] plot[domain=135:315,samples=181] ({1+cos(\x)},{sin(\x)},{sqrt(2+2*cos(\x))});
% cylincer, back bottom
\draw[cylinder back] (L1) arc (315:135:1) -- (R3) arc (135:315:1) -- cycle;
% z-axis
\draw[axis] (O) -- (0,0,4) node [above] {$z$};
% cylincer, front top
\draw[cylinder front] (L3) arc (-45:135:1) -- (R2) --
plot[domain=135:0,samples=136] ({1+cos(\x)},{sin(\x)},{sqrt(2+2*cos(\x))}) -- (B) -- cycle;
\draw[blue] plot[domain=315:360,samples=46] ({1+cos(\x)},{sin(\x)},{sqrt(2+2*cos(\x))});
% cone front
\draw[cone front] (O) -- (R4) arc (90:0:3) -- cycle;
% cylinder, front bottom
\draw[cylinder front] (B) -- (L1) arc (-45:135:1) -- (R2) --
plot[domain=135:0,samples=136] ({1+cos(\x)},{sin(\x)},{sqrt(2+2*cos(\x))});
% to show the coordinates (remove this if you don't need it)
\foreach\j in {L,R} \foreach\i in {1,2,3,4}
\fill (\j\i) circle (0.75pt);
\foreach\j in {A,B}
\fill (\j) circle (0.75pt);
\end{tikzpicture}
\end{document}