How to make nice 3D "potatoes" with tikz (mathematical domain or structural mechanics)
Here is a brief Asymptote
MWE
:
// potato.asy
import graph3;
size(8cm,0);
currentprojection=orthographic(camera=(190,10,180),up=(0,-5,0),target=(0,0,0),zoom=1);
triple[] bot={( 34, 36,0),( 11, 64,0),(-23, 65,0),(-39, 32,0),(-30, 0,0),(-38,-38,0),(-22,-61,0),( 27,-61,0),( 45,-32,0),( 35, -5,0),};
guide3 gBot=graph(bot,operator..)..cycle;
guide3 gTop, gMid;
gTop=shift(0,0, 50)*scale3(0.8)*gBot;
gMid=shift(0,0, 30)*scale3(1.1)*gBot;
triple f(pair uv){
real u=uv.x, v=uv.y;
guide3 g=relpoint(gBot,u)..relpoint(gMid,u)..relpoint(gTop,u);
return relpoint(g,v);
}
surface s=surface(f,(0,0),(1,1),Spline);
draw(s,gray(0.85));
draw(surface(gTop),gray(0.87),nolight);
triple ref1=relpoint(gTop,0.6);
triple ref2=relpoint(gTop,0.9);
triple ref3=relpoint(gTop,0.4);
triple v0,dfn,dfs,df;
v0=0.5ref1+0.5ref2;
dfn=40*unit(cross(ref2-v0,ref3-v0));
dfs=50*unit(ref1-v0);
df =dfn+dfs;
real a=6, dz=0.01;
draw(
surface((v0+(-a,-a,dz))--(v0+(a,-a,dz))--(v0+(a,a,dz))--(v0+(-a,a,dz))--cycle )
,lightred,nolight
);
arrowbar3 ar=Arrow3(size=8);
draw(v0--(v0+dfn),red +1.2bp, ar);
draw(v0--(v0+dfs),green+1.2bp, ar);
draw(v0--(v0+df ),blue +1.2bp, ar);
dot(v0,black+3bp);
label("$\Delta\mathbf{f_n}$",project(v0+dfn),plain.S);
label("$\mathbf{n}$",project(v0+dfn*0.5),plain.S);
label("$\Delta\mathbf{f_s}$",project(v0+dfs),plain.N);
label("$s$",project(v0+0.4dfs),plain.W);
label("$\Delta\mathbf{f}$",project(v0+df),plain.N);
label("$\Delta a$",project(v0+(0,a,dz)),plain.S);//rgb(0.97 ,0.6,0.6));
label("$M$",project(v0+(a,a,dz)),plain.W);//rgb(0.97 ,0.6,0.6));
triple fscar(real t){
real u0=0.77, v0=0.6;
real u1=0.81, v1=0.5;
triple scarBot=f((0.81, 0.5));
triple scarTop=f((0.77, 0.6));
return f((u0*(1-t)+u1*t,v0*(1-t)+v1*t));
}
guide3 gscar=graph(fscar,0,1);
draw(gscar,red+1.4bp);
triple w0=relpoint(gscar,0);
triple w1=relpoint(gscar,0.5);
triple w2=relpoint(gscar,1);
triple dw=(-30,20,0);
draw((w0-dw)--(w0-0.07*dw),red+1.2bp,ar);
draw((w1-dw)--(w1-0.07*dw),red+1.2bp,ar);
draw((w2-dw)--(w2-0.07*dw),red+1.2bp,ar);
Compiled to potato.pdf
with
asy -f pdf -noprc -render=0 potato.asy
The "potato" shape is based on a single contour
guide3 gBot=graph(bot,operator..)..cycle;
and two its scaled and shifted clones,
gTop=shift(0,0, 50)*scale3(0.8)*gBot;
gMid=shift(0,0, 30)*scale3(1.1)*gBot;
The point on the side surface is constructed as an u-v
surface
triple f(pair uv){
real u=uv.x, v=uv.y;
guide3 g=relpoint(gBot,u)..relpoint(gMid,u)..relpoint(gTop,u);
return relpoint(g,v);
}
for u,v=0..1
:
surface s=surface(f,(0,0),(1,1),Spline);
Note that a "scar" is really a curve,
located on the surface, using the same function f
,
scar points are found as
triple fscar(real t){
real u0=0.77, v0=0.6;
real u1=0.81, v1=0.5;
triple scarBot=f((0.81, 0.5));
triple scarTop=f((0.77, 0.6));
return f((u0*(1-t)+u1*t,v0*(1-t)+v1*t));
}
for t=0..1
:
guide3 gscar=graph(fscar,0,1);