3

When I run the following code, the program seems to go into an infinite loop. If I write a function without the abs function, the program runs normally. The resulting plot is similar to the picture given below. What is the problem with my code?

enter image description here

\documentclass[10pt,a4paper]{article}
\usepackage{lmodern}
\usepackage{asypictureB}
\begin{asyheader}
settings.outformat="png";
settings.render=8;
import graph3;
import smoothcontour3;

material surfacepen = material(white, emissivepen = gray(0.2));
    
\end{asyheader}

%
\begin{document}
%
\begin{asypicture}{name=ellipsoid}
size(5cm,0);
currentprojection = orthographic(12/3,12/4,12/2);

real f(real x, real y, real z) {
    return (abs(x))^(0.7) + (abs(y))^(0.7) + (abs(z))^(0.7) - 1;
}

draw(implicitsurface(f, (-1,-1,-1), (1,1,1), overlapedges=true), surfacepen=surfacepen);

xaxis3(Label("$x$",1),-4,4,blue);
yaxis3(Label("$y$",1),-4,4,blue);
zaxis3(Label("$z$",1),-4,4,blue);

\end{asypicture}

\end{document}

1 Answer 1

2

Due to the power 0.7, the surface is not smooth in x=0 or y=0 or z=0. Even if you try implicitsurface(f,(0,0,0),(1,1,1)) I am not sure that the computation will stop. With (0.001,0.001,00.001) it is ok but the surface is not complete.

Here you have a not-too-complicated expression : it is possible to give a parametric of the part with non negative coordinates. Here a possible solution

import graph3;
//import smoothcontour3;
import palette;
material surfacepen = material(white, emissivepen = gray(0.2));

size(5cm,0);
//currentprojection = orthographic(12/3,12/4,12/2);

triple g(pair t){return (t.x, (1-(t.x)^.7)^(1/.7)*t.y,(1-(t.x)^.7-((1-(t.x)^.7)^(1/.7)*t.y)^.7)
                                                       );}
surface s0=surface(g,(0,0),(1,1),30,30,Spline);
surface s1=rotate(90,(0,0,0),(0,0,1))*s0;
surface s2=rotate(180,(0,0,0),(0,0,1))*s0;
surface s3=rotate(270,(0,0,0),(0,0,1))*s0;

surface s=surface(s0,s1,s2,s3);
surface sb=reflect((0,0,0),X,Y)*s;
draw(s,surfacepen=surfacepen);
draw(sb,surfacepen=surfacepen);

and a screenshot of the result (I have some OpenGL pb) enter image description here

Perhaps that a polar parametric could be better.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .