我想在 tikz 中制作以下东西-
- 实心圆柱体
- 空心圆柱体
实心圆柱略微倾斜,接触空心圆柱的顶面。空心圆柱两端开口。以下是我的代码-
\begin{tikzpicture}[scale=0.5, transform shape]
\begin{scope}[shift={(0,0)},rotate=30]
\coordinate (ll) at (-2,0); %lower left
\coordinate (lr) at ( 2,0); %lower right
\coordinate (ul) at (-2,4); %upper left
\coordinate (ur) at ( 2,4); %upper right
\shade [shading angle=90] (ll) arc (-180:-60:2 cm and .75cm) -- +(0,4) arc (-60:-180:2 cm and .75cm) -- cycle;
\shade [shading angle=270] (lr) arc (0:-60:2 cm and .75cm) -- +(0,4) arc (-60:0:2 cm and .75cm) -- cycle;
\draw [thick] (ll) arc (-180:0:2 cm and .75cm) -- (ur) arc (0:-180:2 cm and .75cm) -- cycle;
\draw [thick, shade, shading angle=30] (ul) arc (-180:180:2 cm and .75cm);
\end{scope}
\fill [top color=gray!50!black,bottom color=gray!10,middle color=gray,shading=axis,opacity=0.25] (0,0) circle (2cm and 0.5cm);
\fill [left color=gray!50!black,right color=gray!50!black,middle color=gray!50,shading=axis,opacity=0.25] (2,0) -- (2,-6) arc (360:180:2cm and 0.5cm) -- (-2,0) arc (180:360:2cm and 0.5cm);
\fill [top color=gray!90!,bottom color=gray!2,middle color=gray!30,shading=axis,opacity=0.25] (0,-6) circle (2cm and 0.5cm);
\draw (-2,-6) -- (-2,0) arc (180:360:2cm and 0.5cm) -- (2,-6) ++ (-2,0) circle (2cm and 0.5cm);
\draw [densely dashed] (-2,0) arc (180:0:2cm and 0.5cm);
\end{tikzpicture}
以下是生成的图片 -
上面的输出很好,但是很难区分空心物体和实心物体。如何实现?
请提出建议。
答案1
这是一个优雅的问题。我刚刚在问题中添加了更多标签 [asymptote]
,因为 Asymptote 似乎是绘制三种复杂圆柱体的合适工具:开孔圆柱、闭孔圆柱和实心圆柱。
- 实心圆柱:厚度为圆柱底面半径的 2 倍的三维线。
- 开口空心圆柱:Asymptote 内置圆柱表面。
- 封闭式空心圆柱体=开放式空心圆柱体+底盘+顶盘。
该表面unitdisk
没有记录渐近线手册,但效果很好。最好运行http://asymptote.ualberta.ca/并用鼠标旋转。
// http://asymptote.ualberta.ca/
unitsize(1cm);
import graph3;
currentprojection=orthographic(3,0,2,center=true,zoom=.9);
//currentlight=light(3,6,4,background=gray+opacity(0.5));
real h=2.5;
pen hollowpen=yellow+opacity(.8);
surface cyl=scale(1,1,h)*unitcylinder;
triple A=(0,0,h+1.5);
transform3 t=shift(0,3,0);
transform3 s=shift(0,-3,0);
// closed hollow cylinder
draw(t*unitdisk,hollowpen);
draw(t*shift(0,0,h)*unitdisk,hollowpen);
draw(t*cyl,hollowpen);
label("closed hollow",t*A);
// open hollow cylinder
draw(s*cyl,hollowpen);
label("open hollow",s*A);
// solid cylinder
real rpt=28.3464567;
pen solidpen=linewidth(2*rpt)+linecap(0)+hollowpen;
path3 c=O--(0,0,h);
draw(c,solidpen);
draw(unitcircle3,orange);
draw(shift(0,0,h)*unitcircle3,orange);
label("solid",A);
//draw(Label("$x$",EndPoint),O--2X,Arrow3());
//draw(Label("$y$",EndPoint),O--2Y,Arrow3());
//draw(Label("$z$",EndPoint),O--3Z,Arrow3());
和opacity(.5)
:
有了opacity(1)
,那就没有透明度了:
俯视图: