如何绘制 3D 心形(为 2D 心形添加深度)

如何绘制 3D 心形(为 2D 心形添加深度)

我已经能够绘制以下心形:

我的心

我正在使用以下代码:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{empty}
\begin{document}
    \begin{tikzpicture}
    \draw[black] (0,0) .. controls (0,0.75) and (-1.5,1.00) .. (-1.5,2)  arc (180:0:0.75);
    \draw[black] (0,0) .. controls (0,0.75) and ( 1.5,1.00) .. ( 1.5,2)  arc (0:180:0.75);
    \end{tikzpicture}
\end{document}

我想旋转心形,并给它增加深度。我希望我的最终绘图是这样的:

我想要的是

我只是想给二维心形添加深度。

有人能帮助我如何旋转并增加我的身材深度吗?

谢谢

答案1

再试一次Asymptote

size(200);
import graph;
import three;

currentprojection=orthographic(camera=(15,-13,9),zoom=1);
currentlight.background=paleyellow+opacity(0.0);
pen heartPen=deepred;
pen topPen=red;

guide g0=arc((-3,0),3,0,180,CW)--((-6,0) .. controls (-6,3) and (0,4) .. (0,8));
guide g=rotate(180)*(g0--(reflect((0,0),(0,6))*reverse(g0))--cycle);

real dw=0.15;

pair wScale(real t){
  pair p=relpoint(g0,t);
  return p+dw*reldir(g0,t)*(0,1);
}

guide gtop0=graph(wScale,0.05,1,operator..);
guide gtop=rotate(180)*(gtop0..(reflect((0,0),(0,6))*reverse(gtop0))--cycle);


draw(extrude(g,3*Z),heartPen,meshpen=nullpen,render(merge=true));
draw(surface(g),heartPen,meshpen=nullpen,render(merge=true));

draw(shift(0,0,3.01)*extrude(gtop,-0.5*Z),topPen,meshpen=nullpen,render(merge=true));
draw(shift(0,0,3.01)*surface(gtop),topPen,meshpen=nullpen,render(merge=true));

在此处输入图片描述

答案2

在等待 TikZ 团队的时候,这里有一个小娱乐活动元帖子

在此处输入图片描述

用 编译lualatex

\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
path base, lid, front, side;
base = ((100,162) .. (140,178){right} .. (195,125){down}
       .. (100,0){curl 0} .. (100,0){curl 0} 
       .. {up}(5,125) .. {right}(60,178) .. (100,162) ..
       cycle) rotated -42 yscaled 1/2;
lid = base shifted 42 up;

numeric a, b; a = 1.57; b = 4.52; % guess work...
front = subpath (3, a) of lid -- subpath (a, 3) of base -- cycle;
side = subpath (3, b) of base -- subpath (b, 3) of lid -- cycle;

color sick; sick = 2/3[red, white];
fill lid withcolor sick;
fill side withcolor 1/4[sick, black];
fill front withcolor 1/16[sick, black];

draw lid; draw front; draw side;
draw subpath (a, b) of lid shifted 10 down;
endfig;
\end{mplibcode}
\end{document}

如果你想要真正的 3D 效果和适当的阴影,你可以尝试渐近线

答案3

一种非常简单的方法,使用 3d tikz 和等距透视,可以是以下内容:

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usetikzlibrary{3d}

\pgfmathsetmacro\a{atan(0.5)} % angle for the tangents

\begin{document}
\begin{tikzpicture}[scale=1.25,x={(-0.866cm,0.5cm)},y={(0.866cm,0.5cm)},z={(0cm,1cm)},line cap=round,line join=round]
  \shade[draw,right color=brown!50!black, left color=brown] (0,2,0) --++ (0,0,0) arc (180:135:1) --++ (0,0,1) --++
        (0,0,0) arc (135:180:1) -- cycle; 
  \shade[draw,right color=brown, left color=white] (0,0,0) --++ (90-2*\a:2) --++ (0,0,0) arc (-2*\a:-45:1) --++
        (0,0,1) --++ (0,0,0) arc (-45:-2*\a:1) --++ (270-2*\a:2) -- cycle;
  \shade[draw,right color=red, left color=white] (0,0,1) --++ (90-2*\a:2) --++ (0,0,0) arc (-2*\a:-45:1) --++
        (0,0,0.2) --++ (0,0,0) arc (-45:-2*\a:1) --++ (270-2*\a:2) -- cycle;
  \shade[draw,right color=red!50!black, left color=red] (0,2,1) --++ (0,0,0) arc (180:135:1) --++ (0,0,0.2) --++
        (0,0,0) arc (135:180:1) -- cycle; 
  \shade[draw,right color=brown!50!black, left color=brown] (0,0,0) --++ (90+2*\a:2) --++ (0,0,0) arc (180+2*\a:135:1) --++
        (0,0,1) --++ (0,0,0) arc (135:180+2*\a:1) --++ (270+2*\a:2) -- cycle ;
  \shade[draw,right color=red!50!black, left color=red] (0,0,1) --++ (90+2*\a:2) --++ (0,0,0) arc (180+2*\a:135:1) --++
        (0,0,0.2) --++ (0,0,0) arc (135:180+2*\a:1) --++ (270+2*\a:2) -- cycle ;
  \draw[fill=red] (0,0,1.2) --++ (90-2*\a:2) --++ (0,0,0) arc (-2*\a:180:1) --++ (0,0,0) arc (0:180+2*\a:1) -- cycle;       
\end{tikzpicture}
\end{document}

其结果是: 在此处输入图片描述

答案4

这只是 Asymptote 的一个起点。黄色盒子里有一颗红心 ^^

在此处输入图片描述

// free rotating with http://asymptote.ualberta.ca/
unitsize(1cm);
import three;
currentprojection=orthographic(-5,-25,20);

pair A=(0,0), B=(0,-3);
path p=A .. controls A+2.5*dir(40) and B+4*dir(30) .. B;
path base=p & reverse(xscale(-1)*p) & cycle;
surface base3=surface(base,XYplane);
surface boundary3=extrude(base,axis=Z);
draw(base3,red);
draw(boundary3,yellow);

相关内容