倾斜的 3D 锥体投影在 xy 平面上

倾斜的 3D 锥体投影在 xy 平面上

我正在尝试获取包含 2 个倾斜锥体且其中心投影到 xy 平面上的图:

在此处输入图片描述

这是我目前根据给出的解决方案所得到的这里

\documentclass[tikz, border=3pt]{standalone}
\usepackage{tikz,tikz-3dplot}
\tdplotsetmaincoords{80}{45}
\tdplotsetrotatedcoords{-90}{180}{-90}

%% style for surfaces
\tikzset{surface/.style={draw=blue!70!black, fill=blue!40!white, fill opacity=.6}}

%% macros to draw back and front of cones
%% optional first argument is styling; others are z, radius, side offset (in degrees)
\newcommand{\coneback}[4][]{
  %% start at the correct point on the circle, draw the arc, then draw to the origin of the diagram, then close the path
  \draw[canvas is xy plane at z=#2, #1] (45-#4:#3) arc (45-#4:225+#4:#3) -- (O) --cycle;
  }
\newcommand{\conefront}[4][]{
  \draw[canvas is xy plane at z=#2, #1] (45-#4:#3) arc (45-#4:-135+#4:#3) -- (O) --cycle;
  }

\begin{document}
\begin{tikzpicture}[tdplot_main_coords]
  \coordinate (O) at (0,0,0);

  %% make sure to draw everything from back to front
  %\coneback[surface]{-1.5}{2.5}{-15}
\coneback[surface]{-3}{2}{-10}
\draw (0,0,-5) -- (O);
\conefront[surface]{-3}{2}{-10}

\coneback[surface]{3}{-2}{-10}
\conefront[surface]{3}{-2}{-10}

\end{tikzpicture}

\end{document}

更新

从下面给出的第一个解决方案来看,这是我使用 XeLaTeX 编译时得到的输出:

在此处输入图片描述

我的机器上是否缺少一些设置,导致我获得此输出?谢谢!

答案1

这也许只是一个开始。地幔边界与基圆的交界点是通过循环计算得出的。

\documentclass[tikz, border=3pt]{standalone}
\usepackage{tikz,tikz-3dplot}
\usetikzlibrary{shadows.blur}
\newcounter{iloop}
\begin{document}
\tdplotsetmaincoords{70}{20}
\begin{tikzpicture}[tdplot_main_coords,font=\sffamily]
  \draw[thick,-stealth] (0,0,0) coordinate(O) -- (4,0,0) coordinate (X) 
   node[pos=0.7,below] {$X$}
  -- (4,4,0) coordinate(XY) -- (0,4,0) coordinate (Y) -- (O)
  node[pos=0.3,left] {$Y$} -- (0,0,4)
  coordinate (Z) node[pos=0.7,left]{Time};
  \path (2.2,2.2,3) coordinate (T) (1.8,1.8,1) coordinate (B) (2,2,0) coordinate
  (C);
  \begin{scope}[shift={(2,2,2)}]
   \tdplotsetrotatedcoords{0}{-10}{0}
   \begin{scope}[tdplot_rotated_coords,canvas is xy plane at z=0]
     \path[fill=gray!30,blur shadow={shadow blur steps=10,shadow xshift=0ex,
        shadow yshift=0ex,shadow blur radius=1.5ex}] (C)
        circle[radius=1cm-0.75ex];
     \pgfmathsetmacro{\maxT}{-90}\pgfmathsetmacro{\maxTT}{-90}
     \pgfmathsetmacro{\minT}{90}\pgfmathsetmacro{\minTT}{-90}
     \pgfmathsetmacro{\maxB}{-90}\pgfmathsetmacro{\maxBB}{-90}
     \pgfmathsetmacro{\minB}{90}\pgfmathsetmacro{\minBB}{-90}
     \setcounter{iloop}{0}
     \loop\stepcounter{iloop}
     \path let \p1=($(T)-(\number\value{iloop}:1)$),\n1={atan2(\y1,\x1)},
      \p2=($(B)-(\number\value{iloop}:1)$),\n2={atan2(\y2,\x2)} in 
      \pgfextra{\ifdim\n1>\maxT pt
       \pgfmathsetmacro{\maxT}{\n1}\xdef\maxT{\maxT}
       \pgfmathsetmacro{\maxTT}{\number\value{iloop}}\xdef\maxTT{\maxTT}
       \fi
       \ifdim\n1<\minT pt
       \pgfmathsetmacro{\minT}{\n1}\xdef\minT{\minT}
       \pgfmathsetmacro{\minTT}{\number\value{iloop}}\xdef\minTT{\minTT}
       \fi
       \ifdim\n2>\maxB pt
       \pgfmathsetmacro{\maxB}{\n2}\xdef\maxB{\maxB}
       \pgfmathsetmacro{\maxBB}{\number\value{iloop}}\xdef\maxBB{\maxBB}
       \fi
       \ifdim\n2<\minB pt
       \pgfmathsetmacro{\minB}{\n2}\xdef\minB{\minB}
       \pgfmathsetmacro{\minBB}{\number\value{iloop}}\xdef\minBB{\minBB}
       \fi};
     \ifnum\value{iloop}<360\repeat  
     \draw[thick,left color=blue!60,right color=blue!60,middle color=blue,
        shading angle=180-\minBB/2-\maxBB/2,fill opacity=0.6] (\minBB:1) -- (B) -- (\maxBB:1) 
        arc(\maxBB:\minBB:1);
     \draw[thick,fill=gray!60] circle[radius=1cm];
     \draw[thick,left color=blue!60,right color=blue!60,middle color=blue!20,
        shading angle=180-\minTT/2-\maxTT/2,fill opacity=0.6] (\minTT:1) -- (T) -- (\maxTT:1) arc(\maxTT-360:\minTT:1);
   \end{scope}
  \end{scope}  
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容