答案1
这是一个看起来像水滴的表面:
settings.outformat = "png";
settings.render = 4;
import three;
size(10cm);
path half_droplet = (0,1){dir(-90 + 10 /*degrees*/)} .. (0.3,0.5) .. {W}(0,0);
// Subdivide the path to produce a smoother image in the surface of revolution.
half_droplet = subpath(half_droplet, 0, 1) &
subpath(half_droplet, 1, 4/3) &
subpath(half_droplet, 4/3, 5/3) &
subpath(half_droplet, 5/3, 2);
path3 half_droplet_3d = path3(half_droplet, YZplane);
// Create a surface of revolution.
surface droplet = surface(half_droplet_3d, c=O, axis=Z, n=32);
draw(droplet, white);
要在图像中将水滴置于原点,例如https://tex.stackexchange.com/a/160528/484和https://tex.stackexchange.com/a/275592/484,将以下代码附加到任一答案:
// draw inner "droplet" sphere
path half_droplet = (0,1){dir(-90 + 10 /*degrees*/)} .. (0.3,0.5) .. {W}(0,0);
// Subdivide the path to produce a smoother image in the surface of revolution.
half_droplet = subpath(half_droplet, 0, 1/2) &
subpath(half_droplet, 1/2, 1) &
subpath(half_droplet, 1, 4/3) &
subpath(half_droplet, 4/3, 5/3) &
subpath(half_droplet, 5/3, 2);
path3 half_droplet_3d = path3(half_droplet, YZplane);
// Create a surface of revolution.
surface droplet = surface(half_droplet_3d, c=O, axis=Z, n=32);
// Shift the droplet to surround at the origin.
droplet = shift(-0.3Z) * droplet;
// Draw the droplet, scaled down.
draw(scale3(0.2r) * droplet, emissive(gray));