![买者自负 ...](https://linux22.com/image/344251/%E4%B9%B0%E8%80%85%E8%87%AA%E8%B4%9F%20....png)
代码:
\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}
//================ Format =================
settings.outformat = "pdf";
settings.prc = false;
settings.render = 0;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));
//================ Drawing ===================
path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;
triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];
triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];
triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];
face[] faces;
filldraw(faces.push(pl),project(pl), white+opacity(0.6));
filldraw(faces.push(pl1),project(pl1),white+opacity(0.6));
filldraw(faces.push(pl2),project(pl2),white+opacity(0.6));
filldraw(faces.push(pl3),project(pl3),white+opacity(0.6));
add(faces);
draw(B--A);
draw(C--D);
draw(E--F);
dot(A,red);
dot(B,red);
dot(C,red);
dot(D,red);
dot(E,red);
dot(F,red);
\end{asy}
如果我在上面的代码的最末尾添加以下标签:
label("$A$",A,S);
label("$B$",B,S);
label("$C$",C,S);
label("$D$",D,S);
label("$E$",E,S);
label("$F$",F,S);
\end{asy}
\end{document}
问题 #1:为什么它会转移积分?
问题2:如何让线 CD 被平面“覆盖”?因此,我希望它看起来像平面的不可见边缘:不是整个 CD,而是它唯一不可见的部分。
答案1
请注意,我对 Asymptote 一无所知。
买者自负 ...
这个答案几乎完全来自 Charles Staats 的精彩教程,感兴趣的读者可以去那里寻找更多细节和更正确的建议!
如果你使用settings.render=0
,那么 Asymptote 会按照给定的顺序绘制事物,就像我们在 2D Ti 中一样钾Z。因此,settings.render
需要将其设置为其他值以便平面“覆盖”下面分层的东西。
我猜,这些也应该真的是表面,也许带有no light
。
\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}
settings.outformat = "pdf";
settings.prc = false;
settings.render = 16;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));
path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;
draw (pl);
draw (pl1);
draw (pl2);
draw (pl3);
triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];
triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];
triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];
surface s1=surface(pl);
draw(s1,white+opacity(.6),light=nolight);
surface s2=surface(pl1);
draw(s2,white+opacity(.6),light=nolight);
surface s3=surface(pl2);
draw(s3,white+opacity(.6),light=nolight);
surface s4=surface(pl3);
draw(s4,white+opacity(.6),light=nolight);
draw(B--A);
draw(C--D);
draw(E--F);
dot(A,red);
dot(B,red);
dot(C,red);
dot(D,red);
dot(E,red);
dot(F,red);
//From Charles Staats's tutorial
//Direction of a point toward the camera.
triple cameradirection(triple pt, projection P=currentprojection) {
if (P.infinity) {
return unit(P.camera);
} else {
return unit(P.camera - pt);
}
}
//Move a point closer to the camera.
triple towardcamera(triple pt, real distance=1, projection P=currentprojection) {
return pt + distance * cameradirection(pt, P);
}
label("$A$",align=NE,position=towardcamera((A)));
label("$B$",align=S,position=towardcamera((B)));
label("$C$",align=SE,position=towardcamera((C)));
label("$D$",align=SE,position=towardcamera((D)));
label("$E$",align=NE,position=towardcamera((E)));
label("$F$",align=S,position=towardcamera((F)));
\end{asy}
\end{document}
编辑
如果你只是必须有矢量图形 - 这是问题中没有提到的限制 - 那么你需要注意绘图顺序你自己。这需要将每个表面分割成碎片,然后根据它们相对于其他碎片的位置重新组装。
settings.render=0
这是一个用来确保矢量输出的示例。
右边的图表使用颜色来表明绘制顺序(据我所知)是正确的。左边的版本完全相同,只是它使用white
颜色来代替表面,并且没有指定绘制轮廓的颜色。
\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}
settings.outformat = "pdf";
settings.prc = false;
settings.render = 0;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));
path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;
triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];
triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];
triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];
path3 q11=(D -- -Y -- C-Y -- C -- cycle);
surface sq11=surface(q11);
draw(sq11,white+opacity(.6),light=nolight);
draw(D -- -Y -- C-Y -- C--cycle);
path3 q21=rotate(-28,X)*q11;
surface sq21=surface(q21);
draw(sq21,white+opacity(.6),light=nolight);
draw(rotate(-28,X)*(D -- -Y -- C-Y -- C -- cycle));
path3 q31=(D--C--A--B--cycle);
surface sq31=surface(q31);
draw(sq31,white+opacity(.6),light=nolight);
draw(D--C--A--B--cycle);
path3 q34=(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle);
surface sq34=surface(q34);
draw(sq34,white+opacity(.6),light=nolight);
draw(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle);
path3 q22=(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle);
surface sq22=surface(q22);
draw(sq22,white+opacity(.6),light=nolight);
draw(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle);
path3 q12=(D -- C -- E -- F -- cycle);
surface sq12=surface(q12);
draw(sq12,white+opacity(.6),light=nolight);
draw(q12);
surface s4=surface(pl3);
draw(s4,white+opacity(.6),light=nolight);
draw(pl3);
path3 q32=(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle);
surface sq32=surface(q32);
draw(sq32,white+opacity(.6),light=nolight);
draw(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle);
path3 q13=(Y -- C+Y -- E -- F -- cycle);
surface sq13=surface(q13);
draw(sq13,white+opacity(.6),light=nolight);
draw(Y -- C+Y -- E -- F -- cycle);
dot(A,red);
dot(B,red);
dot(C,red);
dot(D,red);
dot(E,red);
dot(F,red);
//From Charles Staats's tutorial
//Direction of a point toward the camera.
triple cameradirection(triple pt, projection P=currentprojection) {
if (P.infinity) {
return unit(P.camera);
} else {
return unit(P.camera - pt);
}
}
//Move a point closer to the camera.
triple towardcamera(triple pt, real distance=1, projection P=currentprojection) {
return pt + distance * cameradirection(pt, P);
}
label("$A$",align=NE,position=towardcamera((A)));
label("$B$",align=S,position=towardcamera((B)));
label("$C$",align=SE,position=towardcamera((C)));
label("$D$",align=SW,position=towardcamera((D)));
label("$E$",align=NE,position=towardcamera((E)));
label("$F$",align=S,position=towardcamera((F)));
\end{asy}
\begin{asy}
settings.outformat = "pdf";
settings.prc = false;
settings.render = 0;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));
path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;
triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];
triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];
triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];
path3 q11=(D -- -Y -- C-Y -- C -- cycle);
surface sq11=surface(q11);
draw(sq11,red+opacity(.6),light=nolight);
draw(D -- -Y -- C-Y -- C--cycle,red);
path3 q21=rotate(-28,X)*q11;
surface sq21=surface(q21);
draw(sq21,blue+opacity(.6),light=nolight);
draw(rotate(-28,X)*(D -- -Y -- C-Y -- C -- cycle),blue);
path3 q31=(D--C--A--B--cycle);
surface sq31=surface(q31);
draw(sq31,green+opacity(.6),light=nolight);
draw(D--C--A--B--cycle,green);
path3 q34=(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle);
surface sq34=surface(q34);
draw(sq34,green+opacity(.6),light=nolight);
draw(C -- D -- rotate(-56,X)*(D+Y) -- rotate(-56,X)*(C+Y) -- cycle,green);
path3 q22=(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle);
surface sq22=surface(q22);
draw(sq22,blue+opacity(.6),light=nolight);
draw(C -- D -- rotate(-28,X)*(D+Y) -- rotate(-28,X)*(C+Y) -- cycle,blue);
path3 q12=(D -- C -- E -- F -- cycle);
surface sq12=surface(q12);
draw(sq12,red+opacity(.6),light=nolight);
draw(q12,red);
surface s4=surface(pl3);
draw(s4,yellow+opacity(.6),light=nolight);
draw(pl3,yellow);
path3 q32=(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle);
surface sq32=surface(q32);
draw(sq32,green+opacity(.6),light=nolight);
draw(rotate(-56,X)*(D-Y) -- rotate(-56,X)*(C-Y) -- A -- B -- cycle,green);
path3 q13=(Y -- C+Y -- E -- F -- cycle);
surface sq13=surface(q13);
draw(sq13,red+opacity(.6),light=nolight);
draw(Y -- C+Y -- E -- F -- cycle,red);
dot(A,red);
dot(B,red);
dot(C,red);
dot(D,red);
dot(E,red);
dot(F,red);
//From Charles Staats's tutorial
//Direction of a point toward the camera.
triple cameradirection(triple pt, projection P=currentprojection) {
if (P.infinity) {
return unit(P.camera);
} else {
return unit(P.camera - pt);
}
}
//Move a point closer to the camera.
triple towardcamera(triple pt, real distance=1, projection P=currentprojection) {
return pt + distance * cameradirection(pt, P);
}
label("$A$",align=NE,position=towardcamera((A)));
label("$B$",align=S,position=towardcamera((B)));
label("$C$",align=SE,position=towardcamera((C)));
label("$D$",align=SW,position=towardcamera((D)));
label("$E$",align=NE,position=towardcamera((E)));
label("$F$",align=S,position=towardcamera((F)));
\end{asy}
\end{document}