TransWikia.com

Can I remove the front planes of the 3D grid when using the Asymptote package?

TeX - LaTeX Asked by Allan Ray on August 1, 2021

I have the following image based on the code below. Is there a way to remove the front planes so that the 3D surface will really appear to be inside the box? Thank you.

3d surface in box

    settings.render=0;
    import graph3;
    import smoothcontour3;
    import palette;
    import grid3;
    
    size3(10cm, IgnoreAspect);
    
    limits((-3,-3,-3),(3,3,3));
    xaxis3(Label("$x$",0.5),Bounds,InTicks);
    yaxis3(Label("$y$",0.5),Bounds,InTicks);
    zaxis3(Label("$z$",0.5),Bounds,InTicks);
    grid3(XYZgrid, above=true);
    currentprojection=orthographic(0.75,3,1);
    
    real f(real x, real y, real z) {return ((x^2 -x -2)*(y^2 + 2*y)) -z;}
    
    surface s=implicitsurface(f,(-3,-3,-3),(3,-1,3),overlapedges=true);
    s.colors(palette(s.map(zpart),Gradient(rgb(0.24,0.67,0.79)+opacity(0.83), rgb(0.86,0.94,0.96)+opacity(0.83))));
    draw(s,render(merge=true),light=nolight);
    draw((0.5,-1,-3)--(0.5,-1,2.25),red+dashed+linewidth(2));
    surface s=implicitsurface(f,(-3,-1,-3),(3,3,3),overlapedges=true);
    s.colors(palette(s.map(zpart),Gradient(rgb(0.24,0.67,0.79)+opacity(0.83), rgb(0.86,0.94,0.96)+opacity(0.83))));
    draw(s,render(merge=true),light=nolight);

One Answer

Here's my workaround but I still wonder if there's a more efficient way to do this.

settings.render=0;
import graph3;
import smoothcontour3;
import palette;
import grid3;

size3(10cm, IgnoreAspect);

limits((-3,-3,-3),(3,3,3));
xaxis3(Label("$x$",0.5),Bounds,InTicks);
yaxis3(Label("$y$",0.5,align=(10,0,0)),Bounds,NoTicks3);
zaxis3(Label("$z$",0.5),Bounds,InTicks(Label(align=(0.71,-0.71,0))));
grid3(XYZgrid, above=true);
currentprojection=orthographic(0.75,3,1);

real f(real x, real y, real z) {return ((x^2 -x -2)*(y^2 + 2*y)) -z;}

surface s=implicitsurface(f,(-3,-3,-3),(3,-1,3),overlapedges=true);
s.colors(palette(s.map(zpart),Gradient(rgb(0.24,0.67,0.79)+opacity(0.83), rgb(0.86,0.94,0.96)+opacity(0.83))));
draw(s,render(merge=true),light=nolight);
draw((0.5,-1,-3)--(0.5,-1,2.2),rgb(0.87,0.44,0.14)+dashed+linewidth(2));

surface s=implicitsurface(f,(-3,-1,-3),(3,3,3),overlapedges=true);
s.colors(palette(s.map(zpart),Gradient(rgb(0.24,0.67,0.79)+opacity(0.83), rgb(0.86,0.94,0.96)+opacity(0.83))));
draw(s,render(merge=true),light=nolight);

draw((3,-3,3)--(3,3,3));
draw((-3,3,3)--(3,3,3));
draw((3,3,-3)--(3,3,3));
for(int i=-2; i<=2; ++i) {
label("$"+string(i)+"$", (3,i,-3), align=(2,0,0));
}

enter image description here

Answered by Allan Ray on August 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP