Asymptote 是否定义了与 pst-solides3d 的 fillcolor 和 incolor 等效的命令?

Asymptote 是否定义了与 pst-solides3d 的 fillcolor 和 incolor 等效的命令?

http://pstricks.blogspot.com/2015/02/tore-evide-avec-pst-solides3d.html

在此处输入图片描述

渐近线代码,

settings.render=10;
import graph3;
// import palette;

currentprojection=orthographic(1,1,.5);

size(7cm);
defaultrender.merge=true;

triple f(pair z) {
real u=z.x,v=z.y;
return ((3+ 1.5*cos(u))*cos(v),1.5*sin(u),(3+ 1.5*cos(u))*sin(v));
}

surface s=surface(f,(pi/4,0),(1.75*pi,2pi),24,48,Spline);

draw(s,cyan,black+0.6bp);

draw(Label("$y$",1),(0,-6,0)--(0,6,0),red,Arrow3);
draw(Label("$x$",1),(-6,0,0)--(6,0,0),red,Arrow3);
draw(Label("$z$",1),(0,0,-5)--(0,0,6),red,Arrow3);

在此处输入图片描述

问题:

我怎样才能在 Asymptote 中填充像这个圆环一样的内部和外部?

答案1

这几乎完全复制自这个答案除了我使用你的表面,将颜色改为黑白色,并进行调整n

\documentclass[margin=10pt, convert]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=plane}
settings.render=10;
import graph3;
// import palette;

currentprojection=orthographic(1,1,.5);

size(7cm);
defaultrender.merge=true;

int n = 48;

triple f(pair z) {
real u=z.x,v=z.y;
return ((3+ 1.5*cos(u))*cos(v),1.5*sin(u),(3+ 1.5*cos(u))*sin(v));
}

surface s=surface(f,(pi/4,0),(1.75*pi,2pi),24,48,Spline);

material[] surfacepen = new material[] {black,white};
surfacepen.cyclic = true;
if (n % 2 == 0) {
    surfacepen = sequence(new material(int i) {
            if (i >= n) ++i;
            return surfacepen[i];
            }, 
        2n);
    write(surfacepen.length);
    surfacepen.cyclic=true;
}


draw(s, surfacepen=surfacepen);

draw(Label("$y$",1),(0,-6,0)--(0,6,0),red,Arrow3);
draw(Label("$x$",1),(-6,0,0)--(6,0,0),red,Arrow3);
draw(Label("$z$",1),(0,0,-5)--(0,0,6),red,Arrow3);
\end{asypicture}
\end{document}

在此处输入图片描述

如果您想对曲面的内部和外部进行不同的着色,那么您需要明确这是什么意思。通常,这需要一个可定向的曲面,例如,莫比乌斯带没有内部和外部。当然,就像在 PSTricks 中一样,您可以“手动”完成。

\documentclass[margin=10pt, convert]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=plane}
settings.render=10;
import graph3;
// import palette;

currentprojection=orthographic(1,1,.5);

size(7cm);
defaultrender.merge=true;

int n = 48;

triple fi(pair z) {
real u=z.x,v=z.y;
return ((3+ 1.5*cos(u))*cos(v),1.5*sin(u),(3+ 1.5*cos(u))*sin(v));
}

surface si=surface(fi,(pi/4,0),(1.75*pi,2pi),24,48,Spline);

material[] surfacepeni = new material[] {red,white};
surfacepeni.cyclic = true;
if (n % 2 == 0) {
    surfacepeni = sequence(new material(int i) {
            if (i >= n) ++i;
            return surfacepeni[i];
            }, 
        2n);
    write(surfacepeni.length);
    surfacepeni.cyclic=true;
}


draw(si, surfacepen=surfacepeni);

triple fo(pair z) {
real u=z.x,v=z.y;
return ((3+ 1.501*cos(u))*cos(v),1.501*sin(u),(3+ 1.501*cos(u))*sin(v));
}

surface so=surface(fo,(pi/4,0),(1.75*pi,2pi),24,48,Spline);

material[] surfacepeno = new material[] {black,white};
surfacepeno.cyclic = true;
if (n % 2 == 0) {
    surfacepeno = sequence(new material(int i) {
            if (i >= n) ++i;
            return surfacepeno[i];
            }, 
        2n);
    write(surfacepeno.length);
    surfacepeno.cyclic=true;
}


draw(so, surfacepen=surfacepeno);


draw(Label("$y$",1),(0,-6,0)--(0,6,0),red,Arrow3);
draw(Label("$x$",1),(-6,0,0)--(6,0,0),red,Arrow3);
draw(Label("$z$",1),(0,0,-5)--(0,0,6),red,Arrow3);
\end{asypicture}
\end{document}

在此处输入图片描述

相关内容