我有一个像下面这样的 3D 形式,我想将该标记投影到该形式的每个表面上,包括顶部的表面,但不包括后面的表面。无论如何,我只想知道投影的工作原理以及是否可行
\documentclass{article}
\usepackage{tikz}
\begin{document}
\pagestyle{empty}
% The following code is generated by Sketch. I have edited it a bit
% to make it easier to read.
\begin{tikzpicture}[join=round]
\tikzstyle{conefill} = [fill=blue!20,fill opacity=0.8]
\tikzstyle{ann} = [fill=white,font=\footnotesize,inner sep=1pt]
\tikzstyle{ghostfill} = [fill=white]
\tikzstyle{ghostdraw} = [draw=black!50]
% Second version of the cone
\begin{scope}[xshift=3.5cm]
\filldraw[ghostdraw,ghostfill](-.775,1.922)--(-1.162,.283)--(-.274,.5)
--(-.183,2.067)--cycle;
\filldraw[ghostdraw,ghostfill](-.183,2.067)--(-.274,.5)--(.775,.424)
--(.516,2.016)--cycle;
\filldraw[ghostdraw,ghostfill](.516,2.016)--(.775,.424)--(1.369,.1)
--(.913,1.8)--cycle;
\filldraw[ghostdraw,ghostfill](-.913,1.667)--(-1.369,-.1)--(-1.162,.283)
--(-.775,1.922)--cycle;
\filldraw[ghostdraw,ghostfill](.913,1.8)--(1.369,.1)--(1.162,-.283)
--(.775,1.545)--cycle;
\filldraw[ghostdraw,ghostfill](-.516,1.45)--(-.775,-.424)--(-1.369,-.1)
--(-.913,1.667)--cycle;
\filldraw[ghostdraw,ghostfill](.775,1.545)--(1.162,-.283)--(.274,-.5)
--(.183,1.4)--cycle;
\filldraw[fill=red,fill opacity=0.5](-.516,1.45)--(-.775,-.424)--(.274,-.5)
--(.183,1.4)--cycle;
\fill(-.775,-.424) circle (2pt);
\fill(.274,-.5) circle (2pt);
\fill(-.516,1.45) circle (2pt);
\fill(.183,1.4) circle (2pt);
\path[font=\footnotesize]
(.913,1.8) node[right] {$i\hbox{$=$}0$}
(1.369,.1) node[right] {$i\hbox{$=$}1$};
\path[font=\footnotesize]
(-.645,.513) node[left] {$j$}
(.228,.45) node[right] {$j\hbox{$+$}1$};
\fill[black,font=\footnotesize]
(-.516,1.45) node [above] {$P_{00}$}
(-.775,-.424) node [below] {$P_{10}$}
(.183,1.4) node [above] {$P_{01}$}
(.274,-.5) node [below] {$P_{11}$};
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.1]{download.png}};
\end{scope}
\end{tikzpicture}
\end{document}
答案1
概念证明比其他任何东西都多,但基本思想是在单位正方形上绘制形状,将矢量设置为 1pt(而不是导入它),然后可以使用非线性变换将其拉伸到所需的四边形上。
设置坐标是棘手的(经过多次尝试和错误)。
\documentclass[tikz,border=5]{standalone}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\stretchovertransform{%
\pgfgetlastxy\x\y
\pgfpointlineattime{\y}
{\pgfpointlineattime{\x}{\southwest}{\southeast}}%
{\pgfpointlineattime{\x}{\northwest}{\northeast}}%
}
\tikzset{%
stretch over/.code args={(#1)#2(#3)#4(#5)#6(#7)}{
\pgfextract@process\southwest{\tikz@scan@one@point\relax(#1)}%
\pgfextract@process\northwest{\tikz@scan@one@point\relax(#3)}%
\pgfextract@process\northeast{\tikz@scan@one@point\relax(#5)}%
\pgfextract@process\southeast{\tikz@scan@one@point\relax(#7)}%
\tikzset{reset cm, x=1pt, y=1pt}%
\pgftransformnonlinear{\stretchovertransform}
}
}
\tikzstyle{conefill} = [fill=blue!20,fill opacity=0.8]
\tikzstyle{ann} = [fill=white,font=\footnotesize,inner sep=1pt]
\tikzstyle{ghostfill} = [fill=white]
\tikzstyle{ghostdraw} = [draw=black!50]
\begin{document}
\begin{tikzpicture}[line join=round, line cap=round]
\filldraw[ghostdraw, ghostfill](-.775,1.922)--(-1.162,.283)--(-.274,.5)
--(-.183,2.067)--cycle;
\filldraw[ghostdraw, ghostfill](-.183,2.067)--(-.274,.5)--(.775,.424)
--(.516,2.016)--cycle;
\filldraw[ghostdraw, ghostfill](.516,2.016)--(.775,.424)--(1.369,.1)
--(.913,1.8)--cycle;
\filldraw[ghostdraw, ghostfill](-.913,1.667)--(-1.369,-.1)--(-1.162,.283)
--(-.775,1.922)--cycle;
\filldraw[ghostdraw, ghostfill](.913,1.8)--(1.369,.1)--(1.162,-.283)
--(.775,1.545)--cycle;
\filldraw[ghostdraw, ghostfill]
(-.516,1.45) coordinate (r01) --
(-.775,-.424) coordinate (r11) --
(-1.369,-.1) coordinate (r10) --
(-.913,1.667) coordinate (r00) -- cycle;
\filldraw[ghostdraw, ghostfill]
(.775,1.545) coordinate (q01) --
(1.162,-.283) coordinate (q11) --
(.274,-.5) coordinate (q10) --
(.183,1.4) coordinate (q00) -- cycle;
\filldraw[fill=red,fill opacity=0.5]
(-.516,1.45) coordinate (p00) --
(-.775,-.424) coordinate (p10) --
(.274,-.5) coordinate (p11) --
(.183,1.4) coordinate (p01) --cycle;
\foreach \i in {p,q,r}{
\begin{scope}[stretch over={(\i10) (\i00) (\i01) (\i11)}, shift={(0.5,0.5)}, fill=gray, opacity=.875, scale=0.75]
\fill [even odd rule]
(-.5,-.5) rectangle ++(1, 1) (0,0)
circle [radius=0.375]
(90:.375) -- (210:.375) -- (330:.375)
(90:.25) -- (210:.25) -- (330:.25);
\fill (-.1,-.025) rectangle (.1,.025)
[rotate=90](-.1,-.025) rectangle (.1,.025) ;
\fill [white, shift=(45:.5), scale=0.75] (-.1,-.025) rectangle (.1,.025)
[rotate=90](-.1,-.025) rectangle (.1,.025) ;
\fill [white, shift=(225:.5), scale=0.75] (-.1,-.025) rectangle (.1,.025)
[rotate=90](-.1,-.025) rectangle (.1,.025);
\fill [white, shift=(135:.5), rotate=45] (90:.1) -- (210:.1) -- (330:.1);
\fill [white, shift=(315:.5), rotate=-135] (90:.1) -- (210:.1) -- (330:.1);
\end{scope}
}
\end{tikzpicture}
\end{document}