3d 渐近线图中的投影平面

3d 渐近线图中的投影平面

这是对旧作的后续问题它解决了 3d 图中渐近线箭头看起来很丑的问题。

现在我想在我的绘图中为框添加一个半透明的底层。在这里,将所有内容投影到 2d 的方法似乎已经达到了极限,因为没有可用的表面投影。

那么,有没有其他方法可以让盒子底面呈现半透明色,同时保留红色箭头的美观呢?

settings.outformat = "png";
settings.render = 10;
settings.prc = false;
unitsize(1.0cm);
import three;
real width = 2.7;
real height = 1.6;
real depth = 1.2;
real lw = 2; //linewidth

currentprojection = obliqueX;

//define matplotlib default colors
pen C0 = RGB(31,119,180);
pen C3 = RGB(214,39,40);

//draw box
draw(project((0,0,0) -- (0,0,-height)            ), C0+dashed+linewidth(lw));
draw(project((0,0,-height) -- (0,4*width,-height)), C0+dashed+linewidth(lw));
draw(project((0,0,-height) -- (depth,0,-height)  ), C0+dashed+linewidth(lw));
draw(project((0,0,0) -- (0,4*width,0)            ), C0+linewidth(lw));
draw(project((depth,0,0) -- (0,0,0)              ), C0+linewidth(lw));
draw(project((depth,0,-height) -- (depth,4*width,-height) -- (depth,4*width,0) -- (depth,0,0) -- (depth,0,-height)), C0+linewidth(lw));
draw(project((depth,4*width,-height) -- (0,4*width,-height) -- (0,4*width,0) -- (depth,4*width,0)), C0+linewidth(lw));
label("Box", project((depth, 2*width, -0.40*height)),C0);

//draw axis arrows
real axisZshift = -2.4;
real axisXshift = 0.2;
real axisLength = 1.0;
draw(project((0,axisZshift,axisXshift)--(-axisLength,axisZshift,axisXshift )), arrow=Arrow(TeXHead), L=Label("$z$", position=EndPoint, align=N+E));
draw(project((0,axisZshift,axisXshift)--(0,axisZshift,axisXshift+axisLength)), arrow=Arrow(TeXHead), L=Label("$x$", position=EndPoint, align=N));
draw(project((0,axisZshift,axisXshift)--(0,axisZshift+axisLength,axisXshift)), arrow=Arrow(TeXHead), L=Label("$y$", position=EndPoint, align=E));
//draw top interface DSM-SC
draw(project(shift(0,0,0)*scale(depth,width,height)*unitplane),C0+opacity(0.6));

//draw red arrow
draw(project((depth, 3.5*width, 1.5*height) -- (depth, 0.5*width, 1.5*height)), arrow=Arrow(TeXHead), L=Label("red arrow", position=MidPoint, align=N), C3+linewidth(2*lw));

答案1

您应该以 3D 形式绘制,而不是尝试手动将场景投影到 2D。这样,您就可以使用 OpenGL、WebGL 或 Adob​​e Reader(使用 PRC)从不同视角以交互方式查看您的图形。只需删除项目函数即可。您可能更喜欢具有斜投影的 DefaultHead2 的外观:

draw((depth, 3.5*width, 1.5*height) -- (depth, 0.5*width, 1.5*height), arrow=Arrow3(DefaultHead2,size=30,emissive(C3)), L=Label("red arrow", position=MidPoint, align=N), C3+linewidth(2*lw));

相关内容