嗨,我尝试绘制一个圆柱形域,其中圆柱体的底部不是圆形或椭圆形。
我的知识很差,以前所有的尝试都失败了。
失败的尝试:
\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\begin{tikzpicture}
\draw plot [smooth cycle] coordinates{(0,0) (1,-.5) (1.2,1.5) (0,1) (-.5,.5) (-.7,.2)};
\draw plot [smooth cycle] coordinates{(3,2) (4,1.5) (4.2,3.5) (3,3) (2.5,2.5) (2.3,2.2)};
\draw (1,-.5)--(4,1.5);
\draw (1.2,1.5)--(4.2,3.5);
\end{tikzpicture}
\end{document}
答案1
世界上有很多种方法可以将这样的圆柱体形象化TeX
,这里是利用 光栅输出extrude
功能制作的一种圆柱体Asymptote
。
% cyl.tex :
%
\documentclass{article}
\usepackage[inline]{asymptote}
\usepackage{lmodern}
\begin{document}
\begin{figure}
\begin{asy}
settings.outformat="png";
settings.tex="pdflatex";
settings.render=8;
size(5cm);
import graph3;
import fontsize;
defaultpen(fontsize(9pt));
currentprojection=orthographic(camera=(3,3,6),up=Z,target=O,zoom=1);
currentlight=light(gray(0.8),ambient=rgb(0.1,0.099,0.101),specular=gray(0.7),
specularfactor=3,viewport=true,dir(42,48));
pair[] ppair={(0,0),(1,-.5),(1.2,1.5),(0,1),(-.5,.5),(-.7,.2)};
real height=3;
guide gbase=graph(ppair, Spline)..cycle;
pen bpen=rgb(0.1, 0.1, 0.8)+opacity(0.5);
material m=material(diffusepen=0.7bpen
,ambientpen=bpen,emissivepen=0.3*bpen,specularpen=0.999white,shininess=1.0);
draw(rotate(-90,Y)*rotate(180,Z)*extrude(gbase,height*Z),m,render(merge=true));
xaxis3("$x$",-3.2,1.2,red ,Arrow3);
yaxis3("$y$", -2,2,green,Arrow3);
zaxis3("$z$", -3,3,blue ,Arrow3);
\end{asy}
\end{figure}
\end{document}
%
% Process:
%
% pdflatex cyl.tex
% asy cyl-*.asy
% pdflatex cyl.tex
答案2
看起来你可以使用pgf图例如:
代码
\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[ z buffer=sort,
]
\addplot3[domain=0:360,y domain=0:360,surf,shader=faceted,samples=40]
( {cos(y)+0.1*sin(7*y)},
{x},
{sin(y)+0.1*cos(3*y)}
);
\end{axis}
\end{tikzpicture}
\end{document}
输出
答案3
基地的功能也是可能的。
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-solides3d}
\begin{document}
\psset{viewpoint=50 -20 40 rtp2xyz, Decran=50,linearc=0.2}
\begin{pspicture}(-1,-1)(4,4)
\psSolid[object=prisme,axe=0 0.5 1,
base= 0 0 1 -.5 1.2 1.5 0 1 -.5 .5 -.7 .2 ,
linecolor=red,h=4,action=draw*]
\end{pspicture}
\begin{pspicture}(-1,-1)(4,4)
\psSolid[object=prisme,axe=0 0.5 1,
base= 0 0 1 -.5 1.2 1.5 0 1 -.5 .5 -.7 .2 ,
hollow,fillcolor=red!30,incolor=blue!30,
linecolor=red,h=4,action=draw**]%
\end{pspicture}
\end{document}